/// <summary>
        /// Updates the tags for a <see cref="IRedisCacheItem" />
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="cacheItem">The cache item.</param>
        public async Task<bool> UpdateTagsAsync(RedisClient client, IRedisCacheItem cacheItem)
        {
            await SetTagsForKeyAsync(client, cacheItem);
            await AddKeyToTagsAsync(client, cacheItem);

            return true;
        }
 /// <summary>
 /// Retrieves all keys from the tag lists for the given tag 
 /// </summary>
 /// <param name="client"></param>
 /// <param name="cacheItem"></param>
 public async Task<string[]> GetKeysForTagAsync(RedisClient client, string tag)
 {
     var keys = await client.GetKeysForTagAsync(tag);
     if (keys != null)
     {
         return keys.ToArray();
     }
     return null;
 }
 /// <summary>
 /// Retrieves all keys from the tag lists for the given tag 
 /// </summary>
 /// <param name="client"></param>
 /// <param name="cacheItem"></param>
 public string[] GetKeysForTag(RedisClient client, string tag)
 {
     var keys = client.GetKeysForTag(tag);
     if (keys != null)
     {
         return keys.ToArray();
     }
     return null;
 }
 private string[] GetTagsForKey(RedisClient client, string key)
 {
     var keys = client.GetTagsForKey(key);
     if (keys != null)
     {
         return keys.ToArray();
     }
     return null;
 }
        /// <summary>
        /// Removes the given items key from the tag list for each tag
        /// </summary>
        /// <param name="client"></param>
        /// <param name="cacheItem"></param>
        public async Task<bool> RemoveKeyFromTagsAsync(RedisClient client, IRedisCacheItem cacheItem)
        {
            if (cacheItem != null)
            {
                if (cacheItem.Tags != null && cacheItem.Tags.Any())
                {
                    return await client.RemoveKeyFromTagsAsync(cacheItem.Key, cacheItem.Tags);
                }
            }

            return true;
        }
 /// <summary>
 /// Removes the given items key from the tag list for each tag
 /// </summary>
 /// <param name="client"></param>
 /// <param name="cacheItem"></param>
 public void RemoveKeyFromTags(RedisClient client, IRedisCacheItem cacheItem)
 {
     if (cacheItem != null)
     {
         if (cacheItem.Tags != null && cacheItem.Tags.Any())
         {
             client.RemoveKeyFromTags(cacheItem.Key, cacheItem.Tags);
         }
     }
 }
        /// <summary>
        /// Removes the tags.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="keys">The keys.</param>
        public async Task<bool> RemoveTagsAsync(RedisClient client, string[] keys)
        {
            foreach (var key in keys)
            {
                var tags = GetTagsForKey(client, key);
                var cacheItem = _cacheItemFactory.Create(
                    key: key,
                    tags: tags.ToList()
                    );
                await RemoveKeyFromTagsAsync(client, cacheItem);
                await RemoveTagsForKeyAsync(client, cacheItem);
            }

            return true;
        }
 /// <summary>
 /// Removes the tags.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="keys">The keys.</param>
 public void RemoveTags(RedisClient client, string[] keys)
 {
     foreach (var key in keys)
     {
         var tags = GetTagsForKey(client, key);
         var cacheItem = _cacheItemFactory.Create(
             key: key,
             tags: tags.ToList()
             );
         RemoveKeyFromTags(client, cacheItem);
         RemoveTagsForKey(client, cacheItem);
     }
 }
 public void RemoveKeyExpiry(RedisClient client, string[] keys)
 {
     client.RemoveTimeSet(_setKey, keys);
 }
 public async Task<string[]> GetExpiredKeysAsync(RedisClient client, DateTime maxDate)
 {
     return await client.GetFromTimeSetAsync(_setKey, maxDate);
 }
        /// <summary>
        /// Clears the list of tags for the given key
        /// </summary>
        /// <param name="client"></param>
        /// <param name="cacheItem"></param>
        public async Task<bool> RemoveTagsForKeyAsync(RedisClient client, IRedisCacheItem cacheItem)
        {
            if (cacheItem != null)
            {
                if (cacheItem.Tags != null && cacheItem.Tags.Any())
                {
                    return await client.SetTagsForKeyAsync(cacheItem.Key, null);
                }
            }

            return true;
        }
        /// <summary>
        /// Updates the tags asynchronously.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="key">The key.</param>
        /// <param name="tags">The tags.</param>
        /// <returns></returns>
        public async Task<bool> UpdateTagsAsync(RedisClient client, string key, IEnumerable<string> tags)
        {
            var cacheItem = _cacheItemFactory.Create(
                key: key,
                tags: tags == null ? null : tags.ToList()
            );
            
            await UpdateTagsAsync(client, cacheItem);

            return true;
        }
 public async Task <string[]> GetExpiredKeysAsync(RedisClient client, DateTime maxDate)
 {
     return(await client.GetFromTimeSetAsync(_setKey, maxDate));
 }
 public string[] GetExpiredKeys(RedisClient client, DateTime maxDate)
 {
     return(client.GetFromTimeSet(_setKey, maxDate));
 }
        public async Task <bool> RemoveKeyExpiryAsync(RedisClient client, string[] keys)
        {
            await client.RemoveTimeSetAsync(_setKey, keys);

            return(true);
        }
 public void RemoveKeyExpiry(RedisClient client, string[] keys)
 {
     client.RemoveTimeSet(_setKey, keys);
 }
 public void SetKeyExpiry(RedisClient client, string key, DateTime expiryDate)
 {
     client.SetTimeSet(_setKey, key, expiryDate);
 }
 /// <summary>
 /// Clears the list of tags for the given key
 /// </summary>
 /// <param name="client"></param>
 /// <param name="cacheItem"></param>
 public void RemoveTagsForKey(RedisClient client, IRedisCacheItem cacheItem)
 {
     if (cacheItem != null)
     {
         if (cacheItem.Tags != null && cacheItem.Tags.Any())
         {
             client.SetTagsForKey(cacheItem.Key, null);
         }
     }
 }
        /// <summary>
        /// Removes the tags asynchronous.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="cacheItem">The cache item.</param>
        /// <returns></returns>
        public async Task<bool> RemoveTagsAsync(RedisClient client, IRedisCacheItem cacheItem)
        {
            var remoteKeyTask = RemoveKeyFromTagsAsync(client, cacheItem);
            var removeTagTask = RemoveTagsForKeyAsync(client, cacheItem);

            return await remoteKeyTask && await removeTagTask;
        }
 public async Task<bool> RemoveKeyExpiryAsync(RedisClient client, string[] keys)
 {
     await client.RemoveTimeSetAsync(_setKey, keys);
     return true;
 }
 /// <summary>
 /// Removes the tags from the key list and the key from the tags list
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="cacheItem">The cache item.</param>
 public void RemoveTags(RedisClient client, IRedisCacheItem cacheItem)
 {
     RemoveKeyFromTags(client, cacheItem);
     RemoveTagsForKey(client, cacheItem);
 }
 public string[] GetExpiredKeys(RedisClient client, DateTime maxDate)
 {
     return client.GetFromTimeSet(_setKey, maxDate);
 }
 /// <summary>
 /// Updates the tags for a <see cref="IRedisCacheItem" />
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="cacheItem">The cache item.</param>
 public void UpdateTags(RedisClient client, IRedisCacheItem cacheItem)
 {
     SetTagsForKey(client, cacheItem);
     AddKeyToTags(client, cacheItem);
 }
 /// <summary>
 /// Removes the tags from the key list and the key from the tags list
 /// </summary>
 /// <param name="client"></param>
 /// <param name="key"></param>
 public void RemoveTags(RedisClient client, string key)
 {
     RemoveTags(client, new[]{key});
 }
 /// <summary>
 /// Updates the tags.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="key">The key.</param>
 /// <param name="tags">The tags.</param>
 public void UpdateTags(RedisClient client, string key, IEnumerable<string> tags)
 {
     var cacheItem = _cacheItemFactory.Create(
         key : key,
         tags : tags == null ? null :  tags.ToList()
     );
     UpdateTags(client, cacheItem);
 }
 public void SetKeyExpiry(RedisClient client, string key, DateTime expiryDate)
 {
     client.SetTimeSet(_setKey, key, expiryDate);
 }