Example #1
0
        public IEnumerable <T> Query <T>(string partitionKey, double min, double max) where T : new()
        {
            IRedis redis = (IRedis) new T();

            if (redis.RedisEntityType == RedisEntityType.String)
            {
                var searchPattern = redis.MakeRedisKey(partitionKey);
                if (searchPattern[searchPattern.Length - 1] != '*')
                {
                    searchPattern += "*";
                }
                var keys = RedisContext.SearchKeys(searchPattern);
                return(keys.Select(key => RedisContext.Get <T>(key)).ToList());
            }
            else if (redis.RedisEntityType == RedisEntityType.SortedList)
            {
                var sortedkey = redis.MakeRedisKey(partitionKey).Replace("*", "");
                return(GetSortedSetByRange <T>(sortedkey, min, max));
            }
            return(null);
        }
Example #2
0
        public T Load <T>(string partitionKey, string rangeKey) where T : new()
        {
            IRedis redis = (IRedis) new T();

            if (redis.RedisEntityType == RedisEntityType.String)
            {
                return(RedisContext.Get <T>(redis.MakeRedisKey(partitionKey, rangeKey)));
            }
            else
            {
                throw new NotImplementedException("load will not work with lists");
            }
        }