public IDictionary <string, ICacheResult <T> > Get <T>(IList <string> keys)
        {
            object obj;
            Dictionary <string, ICacheResult <T> > strs = new Dictionary <string, ICacheResult <T> >();

            keys = KeyGen.AttachPrefixToKey(keys);
            IDictionary <string, object> values = LocalCache.Cache.GetValues(keys, null);

            foreach (string key in keys)
            {
                obj = (values == null || !values.Keys.Contains(key) ? null : values[key]);
                strs.Add(KeyGen.DetachPrefixFromKey(key), new CacheResult <T>(obj));
            }
            return(strs);
        }
        private IDictionary <string, ICacheResult> RemoveKeys(string keyPrefix)
        {
            Dictionary <string, ICacheResult> strs = new Dictionary <string, ICacheResult>();

            EndPoint[] endPoints = this.redis.GetEndPoints(false);
            for (int i = 0; i < (int)endPoints.Length; i++)
            {
                EndPoint endPoint = endPoints[i];
                IServer  server   = this.redis.GetServer(endPoint, null);
                IEnumerable <RedisKey> redisKeys = server.Keys(this.db.Database, string.Concat(KeyGen.AttachPrefixToKey(keyPrefix), "*"), 10, (long)0, 0, 0);
                foreach (RedisKey redisKey in redisKeys)
                {
                    string str = KeyGen.DetachPrefixFromKey(redisKey);
                    strs.Add(str, this.Remove(str));
                }
            }
            return(strs);
        }
Exemple #3
0
        public IDictionary <string, ICacheResult <T> > Get <T>(IList <string> keys)
        {
            Dictionary <string, ICacheResult <T> > strs = new Dictionary <string, ICacheResult <T> >();
            SafeBucket instance = SafeBucket.Instance;

            try
            {
                foreach (KeyValuePair <string, IOperationResult <T> > keyValuePair in instance.Bucket.Get <T>(KeyGen.AttachPrefixToKey(keys)))
                {
                    strs.Add(KeyGen.DetachPrefixFromKey(keyValuePair.Key), new CacheResult <T>(keyValuePair.Value));
                }
            }
            finally
            {
                if (instance != null)
                {
                    ((IDisposable)instance).Dispose();
                }
            }
            return(strs);
        }