Ejemplo n.º 1
0
        public ISet GetHashSet(string key, Func <IEnumerable <string> > acquirer = null)
        {
            var redisKey = BuildCacheKey(key);
            var set      = new RedisHashSet(redisKey, this);

            if (!Database.KeyExists(redisKey))
            {
                var items = acquirer?.Invoke();
                if (items != null)
                {
                    set.AddRange(items);
                }
            }

            return(set);
        }
Ejemplo n.º 2
0
        public async Task <ISet> GetHashSetAsync(string key, Func <Task <IEnumerable <string> > > acquirer = null)
        {
            var redisKey = BuildCacheKey(key);
            var set      = new RedisHashSet(redisKey, this);

            if (acquirer != null && !(await Database.KeyExistsAsync(redisKey)))
            {
                var items = await acquirer.Invoke();

                if (items != null)
                {
                    await set.AddRangeAsync(items);
                }
            }

            return(set);
        }