Пример #1
0
 public object KeyDelete(CRIModel model)
 {
     using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(connectionManager.ConnectionString))
     {
         IDatabase db = redis.GetDatabase(model.dbIndex);
         return(new { success = db.KeyDelete(model.key) });
     }
 }
Пример #2
0
        public object ListPush(CRIModel model)
        {
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(connectionManager.ConnectionString))
            {
                IDatabase db     = redis.GetDatabase(model.dbIndex);
                var       val    = (model.param is string || !model.param.GetType().IsByRef) ? model.param : JsonConvert.SerializeObject(model.param);
                var       result = db.ListRightPush(model.key, val.ToString());

                return(new { length = result });
            }
        }
Пример #3
0
        public object StringSet(CRIModel model)
        {
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(connectionManager.ConnectionString))
            {
                IDatabase db = redis.GetDatabase(model.dbIndex);

                var val = (model.param is string || !model.param.GetType().IsByRef) ? model.param : JsonConvert.SerializeObject(model.param);

                return(new { success = db.StringSet(model.key, val.ToString()) });
            }
        }
Пример #4
0
        public object ListRange(CRIModel model)
        {
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(connectionManager.ConnectionString))
            {
                IDatabase db   = redis.GetDatabase(model.dbIndex);
                var       data = db.ListRange(model.key);

                if (model.resultType == ResultType.Object)
                {
                    return(data.Select(v => JToken.Parse(v.ToString())));
                }
                else if (model.resultType == ResultType.String)
                {
                    return(data.Select(v => v.ToString()));
                }

                return(data);
            }
        }
Пример #5
0
        public object StringGet(CRIModel model)
        {
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(connectionManager.ConnectionString))
            {
                IDatabase db   = redis.GetDatabase(model.dbIndex);
                var       data = db.StringGet(model.key);

                if (model.resultType == ResultType.Object)
                {
                    return(JObject.Parse(data.ToString()));
                }
                else if (model.resultType == ResultType.String)
                {
                    return(data.ToString());
                }

                return(data);
            }
        }