Exemple #1
0
        public bool Set(string key, CacheKeyType type, string value, int timeToLive)
        {
            if (!_client.IsConnected)
            {
                return(false);
            }
            IDatabase database = _client.GetDatabase();
            IOperator op       = null;

            switch (type)
            {
            case CacheKeyType.None:
            case CacheKeyType.String:
                op = new RedisString();
                break;

            case CacheKeyType.Hash:
                op = new RedisHash();
                break;

            case CacheKeyType.List:
                op = new RedisList();
                break;

            case CacheKeyType.Set:
                op = new RedisSet();
                break;

            case CacheKeyType.SortedSet:
                op = new RedisSortedSet();
                break;
            }
            if (op == null)
            {
                return(false);
            }
            else
            {
                return(op.Set(database, key, value, timeToLive));
            }
        }