Exemple #1
0
        /// <summary>
        /// Determines whether an item with the given cache key is in the cache.
        /// </summary>
        /// <param name="key">Cache Key</param>
        /// <param name="partitionName">
        /// Optional value for the name of a partition in the application cache. Partitions can be a good way to categorize or group
        /// certain types of items in the cache together.
        /// </param>
        /// <returns>Whether or not there is an item in the cache with that key and partition name</returns>
        public async Task <bool> ContainsAsync(string key, string partitionName = "")
        {
            if (string.IsNullOrEmpty(key))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(partitionName))
            {
                return(await _redisDatabase.KeyExistsAsync(key).ConfigureAwait(false));
            }
            var partitionKey = ComposePartitionKey(partitionName);

            return(await _redisDatabase.HashExistsAsync(partitionKey, key).ConfigureAwait(false));
        }
 /// <summary>
 /// 判断该字段是否存在 hash 中
 /// </summary>
 /// <param name="redisKey"></param>
 /// <param name="hashField"></param>
 /// <returns></returns>
 public async Task <bool> HashExistsAsync(string redisKey, string hashField)
 {
     redisKey = GetKeyForRedis(redisKey);
     return(await _database.HashExistsAsync(redisKey, hashField));
 }