gitee.com/h79/goutils@v1.22.10/thrift/redis_proxy.thrift (about) 1 namespace java com.vibo.redis.thrift 2 namespace go redis_proxy 3 4 const i32 RES_OK = 0 //正确返回 5 const i32 RES_FAIL = 1 //错误返回 6 const i32 RES_WRONG_TYPE = 2 //类型错误 7 const i32 RES_NOT_NULL = 3 //key的值存在,当NX才有效 8 const i32 RES_CONNECTION_REFUSED = 501 //和集群的某些节点断开连接 9 const i32 RES_CANNOT_LOAD_SLOTS = 502 //获取slot信息失败,多出现在启动时连不上集群 10 const i32 RES_CLUSTERDOWN = 503 //集群宕机 11 const i32 RES_MOVED = 301 //当被MOVE的节点失效时出现 12 const i32 RES_ASK = 302 //当被Ask的节点失效时出现 13 14 struct response { 15 1:i32 code, 16 2:string msg, 17 3:string res, 18 } 19 20 struct mResponse{ 21 1:i32 code, 22 2:string msg, 23 3:map<string,string> res, 24 } 25 26 struct lResponse{ 27 1:i32 code, 28 2:string msg, 29 3:list<string> res, 30 } 31 32 struct intResponse{ 33 1:i32 code, 34 2:string msg, 35 3:i64 res, 36 } 37 38 struct mIntResponse{ 39 1:i32 code, 40 2:string msg, 41 3:map<string,i64> res, 42 } 43 44 struct floatResponse{ 45 1:i32 code, 46 2:string msg, 47 3:double res, 48 } 49 50 struct bytesResponse{ 51 1:i32 code, 52 2:string msg, 53 3:binary res, 54 } 55 56 struct mBytesResponse{ 57 1:i32 code, 58 2:string msg, 59 3:map<string,binary> res, 60 } 61 62 struct lBytesResponse{ 63 1:i32 code, 64 2:string msg, 65 3:list<binary> res, 66 } 67 68 struct Z { 69 1:double score, 70 2:string member, 71 } 72 73 struct ZResponse { 74 1:i32 code, 75 2:string msg, 76 3:list<Z> res, 77 } 78 79 service redis_proxy{ 80 /*ping*/ 81 i32 Ping(1:i32 echo) 82 83 i32 redis_proxy_ping(1:i32 echo) 84 85 /*string*/ 86 87 //GetSet获取并更新value到key 88 response GetSet(1:string appid, 2:string key, 3:string value) 89 bytesResponse GetSetBytes(1:string appid, 2:string key, 3:binary value) 90 91 //Set 将字符串值 value 关联到 key 。 92 response Set(1:string appid, 2:string key, 3:string value, 4:i64 ttl) 93 response SetBytes(1:string appid, 2:string key, 3:binary value, 4:i64 ttl) 94 95 //SetNX 当key不存在时 将字符串值 value 关联到 key 。 96 response SetNX(1:string appid, 2:string key, 3:string value, 4:i64 ttl) 97 response SetNXBytes(1:string appid, 2:string key, 3:binary value, 4:i64 ttl) 98 99 //Get 返回 key 所关联的字符串值。 100 response Get(1:string appid, 2:string key) 101 bytesResponse GetBytes(1:string appid, 2:string key) 102 103 //MSet 同时设置一个或多个 key-value 对。 104 response MSet(1:string appid, 2:map<string,string> reqs) 105 response MSetBytes(1:string appid, 2:map<string,binary> reqs) 106 107 //MGet 返回所有(一个或多个)给定 key 的值。 108 mResponse MGet(1:string appid, 2:list<string> keys) 109 mBytesResponse MGetBytes(1:string appid, 2:list<string> keys) 110 111 /*keys*/ 112 //Del 删除给定的一个 key 。 113 intResponse Del(1:string appid, 2:string key) 114 115 //MDel 删除给定的多个 key 。 116 intResponse MDel(1:string appid, 2:list<string> keys) 117 118 //Keys 查找所有符合给定模式 pattern 的 key 。 119 lResponse Keys(1:string appid, 2:string key) 120 121 //Expire 为给定 key 设置生存时间,当 key 过期时(生存时间为 0 ),它会被自动删除。单位是秒 122 response Expire(1:string appid, 2:string key, 3:i64 ttl) 123 124 //TTL 以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live) 125 intResponse TTL(1:string appid, 2:string key) 126 127 response Exists(1:string appid, 2:string key) 128 129 /*Hash*/ 130 //HSet 将哈希表 key 中的域 field 的值设为 value 。 131 response HSet(1:string appid, 2:string key, 3:string field, 4:string value) 132 response HSetBytes(1:string appid, 2:string key, 3:string field, 4:binary value) 133 134 //HSetNX 当可以不存在时, 将哈希表 key 中的域 field 的值设为 value 135 response HSetNX(1:string appid, 2:string key, 3:string field, 4:string value) 136 response HSetNXBytes(1:string appid, 2:string key, 3:string field, 4:string value) 137 138 //HGet 返回哈希表 key 中给定域 field 的值 139 response HGet(1:string appid, 2:string key, 3:string field) 140 bytesResponse HGetBytes(1:string appid, 2:string key, 3:string field) 141 142 response HMSet(1:string appid, 2:string key, 3:map<string,string> fields) 143 response HMSetBytes(1:string appid, 2:string key, 3:map<string,binary> fields) 144 145 mResponse HMGet(1:string appid, 2:string key, 3:list<string> fields) 146 mBytesResponse HMGetBytes(1:string appid, 2:string key, 3:list<string> fields) 147 148 mResponse HGetAll(1:string appid, 2:string key) 149 150 intResponse HDel(1:string appid, 2:string key, 3:string field) 151 152 intResponse MHDel(1:string appid, 2:string key, 3:list<string> fields) 153 154 lResponse HKeys(1:string appid, 2:string key) 155 156 lResponse HVals(1:string appid, 2:string key) 157 158 intResponse HIncrBy(1:string appid, 2:string key, 3:string field, 4:i64 inrc) 159 160 floatResponse HIncrByFloat(1:string appid, 2:string key, 3:string field, 4:double inrc) 161 162 response HExists(1:string appid, 2:string key, 3:string field) 163 164 /*sortedSet*/ 165 //ZAdd 将一个 member 元素及其 score 值加入到有序集 key 当中 166 intResponse ZAdd(1:string appid, 2:string key, 3:Z member) 167 168 //MZAdd 将多个 member 元素及其 score 值加入到有序集 key 当中 169 intResponse MZAdd(1:string appid, 2:string key, 3:list<Z> members) 170 171 //ZCard 返回有序集 key 的基数。 172 intResponse ZCard(1:string appid, 2:string key) 173 174 //ZCount 返回有序集 key 中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数量, 175 //默认闭区间开一在min和max前添加 ( 来使用开区间,min 和 max 可以是 -inf 和 +inf 176 intResponse ZCount(1:string appid, 2:string key, 3:string min, 4:string max)//支持-inf,+inf 和 ( 177 178 //ZRangeWithScores ZRANGE ××× WITHSCORES 返回有序集 key 中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列。 179 //区间分别以下标参数 start 和 stop 指出,包含 start 和 stop 在内。 180 //下标参数 start 和 stop 都以 0 为底,也就是说,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。 181 //你也可以使用负数下标,以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。 182 ZResponse ZRangeWithScores(1:string appid, 2:string key, 3:i64 start, 4:i64 stop) 183 184 //ZRangeByScoreWithScores ZRANGEBYSCORE key min max WITHSCORES LIMIT offset count 返回有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。 185 //有序集成员按 score 值递增(从小到大)次序排列。 186 //默认闭区间开一在min和max前添加 ( 来使用开区间,min 和 max 可以是 -inf 和 +inf 187 //offset和count置0为无效 188 ZResponse ZRangeByScoreWithScores(1:string appid, 2:string key, 3:string min, 4:string max, 5:i64 offset, 6:i64 count) 189 190 //ZRem 移除有序集 key 中的一个成员,不存在的成员将被忽略。 191 intResponse ZRem(1:string appid, 2:string key, 3:string member) 192 193 //MZRem 移除有序集 key 中的多个成员,不存在的成员将被忽略。 194 intResponse MZRem(1:string appid, 2:string key, 3:list<string> members) 195 196 //ZRemRangeByRank 移除有序集 key 中,指定排名(rank)区间内的所有成员。 197 //区间分别以下标参数 start 和 stop 指出,包含 start 和 stop 在内。 198 //下标参数 start 和 stop 都以 0 为底,也就是说,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。 199 //你也可以使用负数下标,以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。 200 intResponse ZRemRangeByRank(1:string appid, 2:string key, 3:i64 start, 4:i64 stop) 201 202 //ZRemRangeByScore 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。 203 //有序集成员按 score 值递增(从小到大)次序排列。 204 //默认闭区间开一在min和max前添加 ( 来使用开区间,min 和 max 可以是 -inf 和 +inf 205 intResponse ZRemRangeByScore(1:string appid, 2:string key, 3:string min, 4:string max) 206 207 //ZIncrBy 为有序集 key 的成员 member 的 score 值加上增量 increment 。可以为负数 208 floatResponse ZIncrBy(1:string appid, 2:string key, 3:double increment, 4:string member) 209 210 //ZScore 返回有序集 key 中,成员 member 的 score 值。 211 floatResponse ZScore(1:string appid, 2:string key, 3:string member) 212 213 /* set*/ 214 intResponse SAdd(1:string appid, 2:string key, 3:string member) 215 216 intResponse MSAdd(1:string appid, 2:string key, 3:list<string> members) 217 218 intResponse SCard(1:string appid, 2:string key) 219 220 response SIsMember(1:string appid, 2:string key, 3:string member) 221 222 lResponse SMembers(1:string appid, 2:string key) 223 224 response SRandMember(1:string appid, 2:string key) 225 226 lResponse SRandMemberN(1:string appid, 2:string key, 3:i64 n) 227 228 intResponse SRem(1:string appid, 2:string key, 3:string member) 229 230 intResponse MSRem(1:string appid, 2:string key, 3:list<string> member) 231 232 /*list*/ 233 234 //将指定的值插入到存于 key 的列表的头部。如果 key 不存在,那么在进行 push 操作前会创建一个空列表 235 intResponse LPush(1:string appid, 2:string key, 3:string value) 236 intResponse LPushByte(1:string appid, 2:string key, 3:binary value) 237 238 //向存于 key 的列表的尾部插入指定的值。如果 key 不存在,那么会创建一个空的列表然后再进行 push 操作 239 intResponse RPush(1:string appid, 2:string key, 3:string value) 240 intResponse RPushByte(1:string appid, 2:string key, 3:binary value) 241 242 //将多个指定的值插入到存于 key 的列表的头部。如果 key 不存在,那么在进行 push 操作前会创建一个空列表 243 intResponse MLPush(1:string appid, 2:string key, 3:list<string> value) 244 intResponse MLPushWithTTL(1:string appid, 2:string key, 3:list<string> value, 4:i64 ttl) 245 intResponse MLPushByteWithTTL(1:string appid, 2:string key, 3:list<binary> value, 4:i64 ttl) 246 247 //向存于 key 的列表的尾部插入多个指定的值。如果 key 不存在,那么会创建一个空的列表然后再进行 push 操作 248 intResponse MRPushWithTTL(1:string appid, 2:string key, 3:list<string> value, 4:i64 ttl) 249 intResponse MRPushByteWithTTL(1:string appid, 2:string key, 3:list<binary> value, 4:i64 ttl) 250 251 //移除并且返回 key 对应的 list 的第一个元素。 252 response LPop(1:string appid, 2:string key) 253 bytesResponse LPopByte(1:string appid, 2:string key) 254 255 //移除并返回存于 key 的 list 的最后一个元素。 256 response RPop(1:string appid, 2:string key) 257 bytesResponse RPopByte(1:string appid, 2:string key) 258 259 intResponse LInsertBefore(1:string appid, 2:string key, 3:string pivot, 4:string value) 260 261 intResponse LInsertAfter(1:string appid, 2:string key, 3:string pivot, 4:string value) 262 263 //返回存储在 key 里的list的长度。 如果 key 不存在,那么就被看作是空list,并且返回长度为 0。 264 //当存储在 key 里的值不是一个list的话,会返回error。 265 intResponse LLen(1:string appid, 2:string key) 266 267 //LLen的多参数版本 268 mIntResponse MLLen(1:string appid, 2:list<string> keys) 269 270 response LSet(1:string appid, 2:string key, 3:i64 index, 4:string value) 271 272 response LIndex(1:string appid, 2:string key, 3:i64 index) 273 274 lResponse LRange(1:string appid, 2:string key, 3:i64 start, 4:i64 stop) 275 276 // 修剪(trim)一个已存在的 list,这样 list 就会只包含指定范围的指定元素。 277 // start 和 stop 都是由0开始计数的, 这里的 0 是列表里的第一个元素(表头),1 是第二个元素,以此类推。 278 response LTrim(1:string appid, 2:string key, 3:i64 start, 4:i64 stop) 279 280 /*cluster*/ 281 response ClusterNodes(1:string appid) 282 283 response ClusterInfo(1:string appid) 284 285 /*server*/ 286 mResponse Info(1:string appid, 2:list<string> sections) 287 response NodeInfo(1:string appid, 2:string addr, 3:list<string> sections) 288 }