public Document GetSingleEntity(EntityKey entityKey) { try { var docWrapper = this._redis.GetWithRetries <CacheDocumentWrapper>(entityKey.ToRedisKey()).Single(); var result = docWrapper.Document; this.OnHit.FireSafely(); return(result); } catch (Exception) { this.OnMiss.FireSafely(); return(null); } }
public void PutSingleLoadedEntity(EntityKey entityKey, Document doc) { try { // again, never overwrite local changes this._redis.SetWithRetries(entityKey.ToRedisKey(), new CacheDocumentWrapper(doc), When.NotExists); } catch (RedisCacheException) { // this means the item existed in cache } catch (Exception ex) { this.Log("An entity with key {0} failed to be put to cache with exception: {1}", entityKey, ex); } }
public virtual void AddEntityToIndex(EntityKey entityKey, Document doc) { try { // putting the entity to cache, but never overwriting local changes this._parent._redis.SetWithRetries(entityKey.ToRedisKey(), new CacheDocumentWrapper(doc), When.NotExists); } catch (RedisCacheException) { // this means the item exists in cache } catch (Exception ex) { this._parent.Log("Error while creating index ({0}): an entity with key {1} failed to be put to cache with exception: {2}", this._searchConditions.Key, entityKey, ex); } this.RedisTransaction.HashSet(this.IndexKeyInCache, entityKey.ToRedisValue(), string.Empty); }