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); }
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)); } } }
async Task _clearAll() { await _entityCache.Delete <List <GeneralSettingsEntity> >(SETTINGS_KEY); }
public async Task Update(TEntity entity) { await AlterRepository.Update(entity); Cache.Delete(entity.Id); }
public async Task DeleteMany(string[] ids) { await BatchRepository.DeleteMany(ids); Cache.Delete(ids); }