Exemplo n.º 1
0
        protected override void SetInner <T>(string key, T value, DateTime expiredTime)
        {
            ValidParams(key);

            using (var client = CreateRedisClient())
            {
                var keyPrefix = GetKeyPrefix(key);
                var kvs       = ObjectHashMappingUtil.ToHash(value, keyPrefix);
                client.SetRangeInHash(CacheName, kvs);
            }
        }
Exemplo n.º 2
0
        public override void SetBatch <T>(IEnumerable <CacheItem <T> > items, DateTime expiredTime)
        {
            List <KeyValuePair <string, string> > datas = new List <KeyValuePair <string, string> >();

            foreach (var item in items)
            {
                var keyPrefix = GetKeyPrefix(item.Key);
                var kvs       = ObjectHashMappingUtil.ToHash(item.Value, keyPrefix);
                datas.AddRange(kvs);
            }

            using (var client = CreateRedisClient())
            {
                client.SetRangeInHash(CacheName, datas);
            }
        }