Exemplo n.º 1
0
        private Dictionary <string, RedisValue> SetHash(string hashKey)
        {
            var hash = new Dictionary <string, RedisValue>();

            _objMemCache.Add(hashKey, hash, null, When.Always);
            return(hash);
        }
        private DisjointedSortedSet SetSortedSet(string key)
        {
            var set = new DisjointedSortedSet();

            _objMemCache.Add(key, set, null, When.Always);
            return(set);
        }
Exemplo n.º 3
0
        private HashSet <RedisValue> AddSet(string setKey)
        {
            HashSet <RedisValue> result = new HashSet <RedisValue>();

            _objMemCache.Add(setKey, result, null, When.Always);

            return(result);
        }
Exemplo n.º 4
0
        internal async Task <RedisValueWithExpiry> GetFromMemoryWithExpiry(string key, Func <Task <RedisValueWithExpiry> > retrieval)
        {
            ValOrRefNullable <RedisValue> cachedValue = _memCache.Get <RedisValue>(key);

            if (cachedValue.HasValue)
            {
                //If we know the expiry, then a trip to redis isn't necessary.
                var expiry = _memCache.GetExpiry(key);
                if (expiry.HasValue)
                {
                    return(CreateRedisValueWithExpiry(cachedValue.Value, expiry.Value));
                }
            }

            RedisValueWithExpiry result = await retrieval();

            //Cache the value and expiry
            _memCache.Add(key, result.Value, result.Expiry, When.Always);

            return(result);
        }