Exemplo n.º 1
0
 /// <summary>
 /// GetByUserIdAsync
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="transContext"></param>
 /// <returns></returns>
 /// <exception cref="CacheException"></exception>
 /// <exception cref="DatabaseException"></exception>
 public Task <IEnumerable <UserClaim> > GetByUserIdAsync(long userId, TransactionContext?transContext = null)
 {
     return(TryCacheAsideAsync(CachedUserClaimsByUserId.Key(userId), dbReader =>
     {
         return dbReader.RetrieveAsync <UserClaim>(uc => uc.UserId == userId, transContext);
     }) !);
 }
Exemplo n.º 2
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="databaseReader"></param>
        /// <param name="cache"></param>
        /// <param name="memoryLockManager"></param>
        /// <exception cref="CacheException"></exception>
        public UserClaimRepo(ILogger <UserClaimRepo> logger, IDatabaseReader databaseReader, ICache cache, IMemoryLockManager memoryLockManager) : base(logger, databaseReader, cache, memoryLockManager)
        {
            EntityAdded += (entity, args) =>
            {
                InvalidateCache(CachedUserClaimsByUserId.Key(entity.UserId).Timestamp(args.UtcNowTicks));
                return(Task.CompletedTask);
            };

            EntityUpdated += (entity, args) =>
            {
                InvalidateCache(CachedUserClaimsByUserId.Key(entity.UserId).Timestamp(args.UtcNowTicks));
                return(Task.CompletedTask);
            };

            EntityDeleted += (entity, args) =>
            {
                InvalidateCache(CachedUserClaimsByUserId.Key(entity.UserId).Timestamp(args.UtcNowTicks));
                return(Task.CompletedTask);
            };
        }
        public static CachedUserClaimsByUserId Key(long userId)
        {
            CachedUserClaimsByUserId item = new CachedUserClaimsByUserId(userId.ToString(GlobalSettings.Culture));

            return(item);
        }