Exemplo n.º 1
0
        public override T FindById(long id)
        {
            if (CachingPolicy == CachingPolicy.Dictionary)
            {
                RefreshCacheIfNeed();
            }
            if ((CachingPolicy != CachingPolicy.None) && (IsWholeCacheValid))
            {
                return(_cache[id]);
            }
            if ((CachingPolicy == CachingPolicy.Demanded) && (_cache[id] != null) && (!_changeReceiver.IsInList(id)))
            {
                return(_cache[id]);
            }
            T result = base.FindById(id);

            if (result != default(T))
            {
                _cache[id] = result;
            }
            else
            {
                _cache.Delete(id);
            }
            if (CachingPolicy != CachingPolicy.None)
            {
                _changeReceiver.RemoveFromList(id);
            }
            return(result);
        }
Exemplo n.º 2
0
        public async Task Delete(T entity)
        {
            var e = await Get(entity.Id);

            if (e == null)
            {
                return;
            }

            using (var lRead = await XNamedLock.Get("entm_" + entity.Id).LockAsync())
            {
                using (var lSave = await _saveLock.LockAsync())
                {
                    if (_memoryCache.Contains(e))
                    {
                        _memoryCache.Remove(e);
                    }

                    await _entityCache.Delete <T>(_getKey(e.Id));
                }
            }
        }
Exemplo n.º 3
0
 async Task _clearAll()
 {
     await _entityCache.Delete <List <GeneralSettingsEntity> >(SETTINGS_KEY);
 }
        public async Task Update(TEntity entity)
        {
            await AlterRepository.Update(entity);

            Cache.Delete(entity.Id);
        }
Exemplo n.º 5
0
        public async Task DeleteMany(string[] ids)
        {
            await BatchRepository.DeleteMany(ids);

            Cache.Delete(ids);
        }