예제 #1
0
        /// <summary>
        /// 移除key
        /// </summary>
        /// <param name="key"></param>
        public async Task <long> RemoveAsync(int dataBase, List <string> key, KeyOperatorEnum keyOperatorEnum = default)
        {
            if (key == null || key.Count() <= 0)
            {
                throw new ArgumentNullException(nameof(key));
            }
            List <string> removeList = new List <string>();

            key.ForEach(item =>
            {
                item = GetKey(item, keyOperatorEnum);
                removeList.Add(item);
            });
            return(await redisBase.DoSave(db => db.KeyDeleteAsync(redisBase.ConvertRedisKeys(removeList)), dataBase).ConfigureAwait(false));
        }
예제 #2
0
        /// <summary>
        /// 移除key
        /// </summary>
        /// <param name="key"></param>
        public void Remove(int dataBase, List <string> key, KeyOperatorEnum keyOperatorEnum = default)
        {
            if (key == null || key.Count() <= 0)
            {
                throw new ArgumentNullException(nameof(key));
            }
            List <string> removeList = new List <string>();

            key.ForEach(item =>
            {
                item = GetKey(item, keyOperatorEnum);
                removeList.Add(item);
            });
            redisBase.DoSave(db => db.KeyDelete(redisBase.ConvertRedisKeys(removeList)), dataBase);
        }
예제 #3
0
 /// <summary>
 /// 移除key
 /// </summary>
 /// <param name="key"></param>
 public void Remove(int dataBase, string key, KeyOperatorEnum keyOperatorEnum = default)
 {
     if (keyOperatorEnum == KeyOperatorEnum.String)
     {
         key = redisPrefixKey.StringPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.List)
     {
         key = redisPrefixKey.ListPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.Set)
     {
         key = redisPrefixKey.SetPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.Hash)
     {
         key = redisPrefixKey.HashPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.SortedSet)
     {
         key = redisPrefixKey.SortedSetKey + key;
     }
     redisBase.DoSave(db => db.KeyDelete(key), dataBase);
 }
예제 #4
0
 /// <summary>
 /// 获取key
 /// </summary>
 /// <param name="key"></param>
 /// <param name="keyOperatorEnum"></param>
 /// <returns></returns>
 private string GetKey(string key, KeyOperatorEnum keyOperatorEnum = default)
 {
     if (keyOperatorEnum == KeyOperatorEnum.String)
     {
         key = redisPrefixKey.StringPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.List)
     {
         key = redisPrefixKey.ListPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.Set)
     {
         key = redisPrefixKey.SetPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.Hash)
     {
         key = redisPrefixKey.HashPrefixKey + key;
     }
     else if (keyOperatorEnum == KeyOperatorEnum.SortedSet)
     {
         key = redisPrefixKey.SortedSetKey + key;
     }
     return(key);
 }
예제 #5
0
 /// <summary>
 /// 判断key是否存在
 /// </summary>
 /// <param name="key"></param>
 public async Task <bool> ExistsAsync(string key, KeyOperatorEnum keyOperatorEnum = default) => await ExistsAsync(redisBase.DefaultDataBase, key, keyOperatorEnum);
예제 #6
0
 /// <summary>
 /// 移除key
 /// </summary>
 /// <param name="key"></param>
 public async Task <long> RemoveAsync(List <string> key, KeyOperatorEnum keyOperatorEnum = default) => await RemoveAsync(redisBase.DefaultDataBase, key, keyOperatorEnum);
예제 #7
0
 /// <summary>
 /// 判断key是否存在
 /// </summary>
 /// <param name="key"></param>
 public bool Exists(string key, KeyOperatorEnum keyOperatorEnum = default) => Exists(redisBase.DefaultDataBase, key, keyOperatorEnum);
예제 #8
0
 /// <summary>
 /// 移除key
 /// </summary>
 /// <param name="key"></param>
 public void Remove(List <string> key, KeyOperatorEnum keyOperatorEnum = default) => Remove(redisBase.DefaultDataBase, key, keyOperatorEnum);
예제 #9
0
 /// <summary>
 /// 判断key是否存在
 /// </summary>
 /// <param name="key"></param>
 public async Task <bool> ExistsAsync(int dataBase, string key, KeyOperatorEnum keyOperatorEnum = default)
 {
     key = GetKey(key, keyOperatorEnum);
     return(await redisBase.DoSave(db => db.KeyExistsAsync(key), dataBase).ConfigureAwait(false));
 }
예제 #10
0
 /// <summary>
 /// 判断key是否存在
 /// </summary>
 /// <param name="key"></param>
 public bool Exists(int dataBase, string key, KeyOperatorEnum keyOperatorEnum = default)
 {
     key = GetKey(key, keyOperatorEnum);
     return(redisBase.DoSave(db => db.KeyExists(key), dataBase));
 }
예제 #11
0
 /// <summary>
 /// 移除key
 /// </summary>
 /// <param name="key"></param>
 public async Task <bool> RemoveAsync(string key, KeyOperatorEnum keyOperatorEnum = default)
 {
     key = GetKey(key, keyOperatorEnum);
     return(await redisBase.DoSave(db => db.KeyDeleteAsync(key)).ConfigureAwait(false));
 }