proxy.go 12.4 KB
Newer Older
Y
Your Name 已提交
1
package redispluginproxy
E
eoLinker API Management 已提交
2 3 4

import (
	redis2 "github.com/eolinker/goku-plugin"
删除  
黄孟柱 已提交
5
	"github.com/go-redis/redis"
E
eoLinker API Management 已提交
6 7 8
	"time"
)

Y
Your Name 已提交
9
//RedisProxy redisProxy
E
eoLinker API Management 已提交
10 11 12 13
type RedisProxy struct {
	redisClient redis.Cmdable
}

Y
Your Name 已提交
14
//Ping ping
E
eoLinker API Management 已提交
15 16
func (p *RedisProxy) Ping() redis2.StatusCmd { return p.redisClient.Ping() }

Y
Your Name 已提交
17
//Del del
E
eoLinker API Management 已提交
18 19
func (p *RedisProxy) Del(keys ...string) redis2.IntCmd { return p.redisClient.Del(keys...) }

Y
Your Name 已提交
20
//Unlink unlink
E
eoLinker API Management 已提交
21 22
func (p *RedisProxy) Unlink(keys ...string) redis2.IntCmd { return p.redisClient.Unlink(keys...) }

Y
Your Name 已提交
23
//Dump dump
E
eoLinker API Management 已提交
24 25
func (p *RedisProxy) Dump(key string) redis2.StringCmd { return p.redisClient.Dump(key) }

Y
Your Name 已提交
26
//Exists exists
E
eoLinker API Management 已提交
27 28
func (p *RedisProxy) Exists(keys ...string) redis2.IntCmd { return p.redisClient.Exists(keys...) }

Y
Your Name 已提交
29
//Expire expire
E
eoLinker API Management 已提交
30 31 32 33
func (p *RedisProxy) Expire(key string, expiration time.Duration) redis2.BoolCmd {
	return p.redisClient.Expire(key, expiration)
}

Y
Your Name 已提交
34
//ExpireAt expireAt
E
eoLinker API Management 已提交
35 36 37 38
func (p *RedisProxy) ExpireAt(key string, tm time.Time) redis2.BoolCmd {
	return p.redisClient.ExpireAt(key, tm)
}

Y
Your Name 已提交
39
//Keys keys
E
eoLinker API Management 已提交
40 41
func (p *RedisProxy) Keys(pattern string) redis2.StringSliceCmd { return p.redisClient.Keys(pattern) }

Y
Your Name 已提交
42
//RandomKey randomKey
E
eoLinker API Management 已提交
43 44
func (p *RedisProxy) RandomKey() redis2.StringCmd { return p.redisClient.RandomKey() }

Y
Your Name 已提交
45
//Rename rename
E
eoLinker API Management 已提交
46 47 48 49
func (p *RedisProxy) Rename(key, newkey string) redis2.StatusCmd {
	return p.redisClient.Rename(key, newkey)
}

Y
Your Name 已提交
50
//RenameNX renameNx
E
eoLinker API Management 已提交
51 52 53 54
func (p *RedisProxy) RenameNX(key, newkey string) redis2.BoolCmd {
	return p.redisClient.RenameNX(key, newkey)
}

Y
Your Name 已提交
55
//Restore restore
E
eoLinker API Management 已提交
56 57 58 59
func (p *RedisProxy) Restore(key string, ttl time.Duration, value string) redis2.StatusCmd {
	return p.redisClient.Restore(key, ttl, value)
}

Y
Your Name 已提交
60
//RestoreReplace restore replace
E
eoLinker API Management 已提交
61 62 63 64
func (p *RedisProxy) RestoreReplace(key string, ttl time.Duration, value string) redis2.StatusCmd {
	return p.redisClient.RestoreReplace(key, ttl, value)
}

Y
Your Name 已提交
65
//Append append
E
eoLinker API Management 已提交
66 67 68 69
func (p *RedisProxy) Append(key, value string) redis2.IntCmd { return p.redisClient.Append(key, value) }

//func (p *RedisProxy) BitCountS(key string, Start, End int64) redis2.IntCmd { return p.redisClient.BitCountS(key,Start,End)}

Y
Your Name 已提交
70
//BitOpAnd bitOpAnd
E
eoLinker API Management 已提交
71
func (p *RedisProxy) BitOpAnd(destKey string, keys ...string) redis2.IntCmd {
Y
Your Name 已提交
72
	return p.redisClient.BitOpAnd(destKey, keys...)
E
eoLinker API Management 已提交
73 74
}

Y
Your Name 已提交
75
//BitOpOr bitOpOr
E
eoLinker API Management 已提交
76
func (p *RedisProxy) BitOpOr(destKey string, keys ...string) redis2.IntCmd {
Y
Your Name 已提交
77
	return p.redisClient.BitOpOr(destKey, keys...)
E
eoLinker API Management 已提交
78 79
}

Y
Your Name 已提交
80
//BitOpXor bitOpXor
E
eoLinker API Management 已提交
81
func (p *RedisProxy) BitOpXor(destKey string, keys ...string) redis2.IntCmd {
Y
Your Name 已提交
82
	return p.redisClient.BitOpXor(destKey, keys...)
E
eoLinker API Management 已提交
83 84
}

Y
Your Name 已提交
85
//BitOpNot bitOpNot
E
eoLinker API Management 已提交
86 87 88 89
func (p *RedisProxy) BitOpNot(destKey string, key string) redis2.IntCmd {
	return p.redisClient.BitOpNot(destKey, key)
}

Y
Your Name 已提交
90
//BitPos bitPos
E
eoLinker API Management 已提交
91
func (p *RedisProxy) BitPos(key string, bit int64, pos ...int64) redis2.IntCmd {
Y
Your Name 已提交
92
	return p.redisClient.BitPos(key, bit, pos...)
E
eoLinker API Management 已提交
93 94
}

Y
Your Name 已提交
95
//Decr decr
E
eoLinker API Management 已提交
96 97
func (p *RedisProxy) Decr(key string) redis2.IntCmd { return p.redisClient.Decr(key) }

Y
Your Name 已提交
98
//DecrBy decrBy
E
eoLinker API Management 已提交
99 100 101 102
func (p *RedisProxy) DecrBy(key string, decrement int64) redis2.IntCmd {
	return p.redisClient.DecrBy(key, decrement)
}

Y
Your Name 已提交
103
//Get get
E
eoLinker API Management 已提交
104 105
func (p *RedisProxy) Get(key string) redis2.StringCmd { return p.redisClient.Get(key) }

Y
Your Name 已提交
106
//GetBit getBit
E
eoLinker API Management 已提交
107 108 109 110
func (p *RedisProxy) GetBit(key string, offset int64) redis2.IntCmd {
	return p.redisClient.GetBit(key, offset)
}

Y
Your Name 已提交
111
//GetRange getRange
E
eoLinker API Management 已提交
112 113 114 115
func (p *RedisProxy) GetRange(key string, start, end int64) redis2.StringCmd {
	return p.redisClient.GetRange(key, start, end)
}

Y
Your Name 已提交
116
//GetSet getSet
E
eoLinker API Management 已提交
117 118 119 120
func (p *RedisProxy) GetSet(key string, value interface{}) redis2.StringCmd {
	return p.redisClient.GetSet(key, value)
}

Y
Your Name 已提交
121
//Incr incr
E
eoLinker API Management 已提交
122 123
func (p *RedisProxy) Incr(key string) redis2.IntCmd { return p.redisClient.Incr(key) }

Y
Your Name 已提交
124
//IncrBy incrBy
E
eoLinker API Management 已提交
125 126 127 128
func (p *RedisProxy) IncrBy(key string, value int64) redis2.IntCmd {
	return p.redisClient.IncrBy(key, value)
}

Y
Your Name 已提交
129
//IncrByFloat incrByFloat
E
eoLinker API Management 已提交
130 131 132 133
func (p *RedisProxy) IncrByFloat(key string, value float64) redis2.FloatCmd {
	return p.redisClient.IncrByFloat(key, value)
}

Y
Your Name 已提交
134
//MGet mget
E
eoLinker API Management 已提交
135 136
func (p *RedisProxy) MGet(keys ...string) redis2.SliceCmd { return p.redisClient.MGet(keys...) }

Y
Your Name 已提交
137
//MSet mset
E
eoLinker API Management 已提交
138 139
func (p *RedisProxy) MSet(pairs ...interface{}) redis2.StatusCmd { return p.redisClient.MSet(pairs) }

Y
Your Name 已提交
140
//MSetNX msetnx
E
eoLinker API Management 已提交
141 142
func (p *RedisProxy) MSetNX(pairs ...interface{}) redis2.BoolCmd { return p.redisClient.MSetNX(pairs) }

Y
Your Name 已提交
143
//Set set
E
eoLinker API Management 已提交
144 145 146 147
func (p *RedisProxy) Set(key string, value interface{}, expiration time.Duration) redis2.StatusCmd {
	return p.redisClient.Set(key, value, expiration)
}

Y
Your Name 已提交
148
//SetBit setbit
E
eoLinker API Management 已提交
149 150 151 152
func (p *RedisProxy) SetBit(key string, offset int64, value int) redis2.IntCmd {
	return p.redisClient.SetBit(key, offset, value)
}

Y
Your Name 已提交
153
//SetNX setnx
E
eoLinker API Management 已提交
154 155 156 157
func (p *RedisProxy) SetNX(key string, value interface{}, expiration time.Duration) redis2.BoolCmd {
	return p.redisClient.SetNX(key, value, expiration)
}

Y
Your Name 已提交
158
//SetXX setxx
E
eoLinker API Management 已提交
159 160 161 162
func (p *RedisProxy) SetXX(key string, value interface{}, expiration time.Duration) redis2.BoolCmd {
	return p.redisClient.SetXX(key, value, expiration)
}

Y
Your Name 已提交
163
//SetRange setRange
E
eoLinker API Management 已提交
164 165 166 167
func (p *RedisProxy) SetRange(key string, offset int64, value string) redis2.IntCmd {
	return p.redisClient.SetRange(key, offset, value)
}

Y
Your Name 已提交
168
//StrLen strLen
E
eoLinker API Management 已提交
169 170
func (p *RedisProxy) StrLen(key string) redis2.IntCmd { return p.redisClient.StrLen(key) }

Y
Your Name 已提交
171
//HDel hDel
E
eoLinker API Management 已提交
172
func (p *RedisProxy) HDel(key string, fields ...string) redis2.IntCmd {
Y
Your Name 已提交
173
	return p.redisClient.HDel(key, fields...)
E
eoLinker API Management 已提交
174 175
}

Y
Your Name 已提交
176
//HExists hExists
E
eoLinker API Management 已提交
177 178 179 180
func (p *RedisProxy) HExists(key, field string) redis2.BoolCmd {
	return p.redisClient.HExists(key, field)
}

Y
Your Name 已提交
181
//HGet hGet
E
eoLinker API Management 已提交
182 183
func (p *RedisProxy) HGet(key, field string) redis2.StringCmd { return p.redisClient.HGet(key, field) }

Y
Your Name 已提交
184
//HGetAll hGetAll
E
eoLinker API Management 已提交
185 186
func (p *RedisProxy) HGetAll(key string) redis2.StringStringMapCmd { return p.redisClient.HGetAll(key) }

Y
Your Name 已提交
187
//HIncrBy hIncrBy
E
eoLinker API Management 已提交
188 189 190 191
func (p *RedisProxy) HIncrBy(key, field string, incr int64) redis2.IntCmd {
	return p.redisClient.HIncrBy(key, field, incr)
}

Y
Your Name 已提交
192
//HIncrByFloat hIncrByFloat
E
eoLinker API Management 已提交
193 194 195 196
func (p *RedisProxy) HIncrByFloat(key, field string, incr float64) redis2.FloatCmd {
	return p.redisClient.HIncrByFloat(key, field, incr)
}

Y
Your Name 已提交
197
//HKeys hKeys
E
eoLinker API Management 已提交
198 199
func (p *RedisProxy) HKeys(key string) redis2.StringSliceCmd { return p.redisClient.HKeys(key) }

Y
Your Name 已提交
200
//HLen hLen
E
eoLinker API Management 已提交
201 202
func (p *RedisProxy) HLen(key string) redis2.IntCmd { return p.redisClient.HLen(key) }

Y
Your Name 已提交
203
//HMGet hMget
E
eoLinker API Management 已提交
204
func (p *RedisProxy) HMGet(key string, fields ...string) redis2.SliceCmd {
Y
Your Name 已提交
205
	return p.redisClient.HMGet(key, fields...)
E
eoLinker API Management 已提交
206 207
}

Y
Your Name 已提交
208
//HMSet hMset
E
eoLinker API Management 已提交
209 210 211 212
func (p *RedisProxy) HMSet(key string, fields map[string]interface{}) redis2.StatusCmd {
	return p.redisClient.HMSet(key, fields)
}

Y
Your Name 已提交
213
//HSet hSet
E
eoLinker API Management 已提交
214 215 216 217
func (p *RedisProxy) HSet(key, field string, value interface{}) redis2.BoolCmd {
	return p.redisClient.HSet(key, field, value)
}

Y
Your Name 已提交
218
//HSetNX hSetNx
E
eoLinker API Management 已提交
219 220 221 222
func (p *RedisProxy) HSetNX(key, field string, value interface{}) redis2.BoolCmd {
	return p.redisClient.HSetNX(key, field, value)
}

Y
Your Name 已提交
223
//HVals hVals
E
eoLinker API Management 已提交
224 225
func (p *RedisProxy) HVals(key string) redis2.StringSliceCmd { return p.redisClient.HVals(key) }

Y
Your Name 已提交
226
//BLPop bLpop
E
eoLinker API Management 已提交
227
func (p *RedisProxy) BLPop(timeout time.Duration, keys ...string) redis2.StringSliceCmd {
Y
Your Name 已提交
228
	return p.redisClient.BLPop(timeout, keys...)
E
eoLinker API Management 已提交
229 230
}

Y
Your Name 已提交
231
//BRPop brpop
E
eoLinker API Management 已提交
232
func (p *RedisProxy) BRPop(timeout time.Duration, keys ...string) redis2.StringSliceCmd {
Y
Your Name 已提交
233
	return p.redisClient.BRPop(timeout, keys...)
E
eoLinker API Management 已提交
234 235
}

Y
Your Name 已提交
236
//BRPopLPush brPopLpush
E
eoLinker API Management 已提交
237 238 239 240
func (p *RedisProxy) BRPopLPush(source, destination string, timeout time.Duration) redis2.StringCmd {
	return p.redisClient.BRPopLPush(source, destination, timeout)
}

Y
Your Name 已提交
241
//LIndex lIndex
E
eoLinker API Management 已提交
242 243 244 245
func (p *RedisProxy) LIndex(key string, index int64) redis2.StringCmd {
	return p.redisClient.LIndex(key, index)
}

Y
Your Name 已提交
246
//LInsert lInsert
E
eoLinker API Management 已提交
247 248 249 250
func (p *RedisProxy) LInsert(key, op string, pivot, value interface{}) redis2.IntCmd {
	return p.redisClient.LInsert(key, op, pivot, value)
}

Y
Your Name 已提交
251
//LInsertBefore lInsertBefore
E
eoLinker API Management 已提交
252 253 254 255
func (p *RedisProxy) LInsertBefore(key string, pivot, value interface{}) redis2.IntCmd {
	return p.redisClient.LInsertBefore(key, pivot, value)
}

Y
Your Name 已提交
256
//LInsertAfter lInsertAfter
E
eoLinker API Management 已提交
257 258 259 260
func (p *RedisProxy) LInsertAfter(key string, pivot, value interface{}) redis2.IntCmd {
	return p.redisClient.LInsertAfter(key, pivot, value)
}

Y
Your Name 已提交
261
//LLen llen
E
eoLinker API Management 已提交
262 263
func (p *RedisProxy) LLen(key string) redis2.IntCmd { return p.redisClient.LLen(key) }

Y
Your Name 已提交
264
//LPop lpop
E
eoLinker API Management 已提交
265 266
func (p *RedisProxy) LPop(key string) redis2.StringCmd { return p.redisClient.LPop(key) }

Y
Your Name 已提交
267
//LPush lPush
E
eoLinker API Management 已提交
268
func (p *RedisProxy) LPush(key string, values ...interface{}) redis2.IntCmd {
Y
Your Name 已提交
269
	return p.redisClient.LPush(key, values...)
E
eoLinker API Management 已提交
270 271
}

Y
Your Name 已提交
272
//LPushX lPushX
E
eoLinker API Management 已提交
273 274 275 276
func (p *RedisProxy) LPushX(key string, value interface{}) redis2.IntCmd {
	return p.redisClient.LPushX(key, value)
}

Y
Your Name 已提交
277
//LRange lRange
E
eoLinker API Management 已提交
278 279 280 281
func (p *RedisProxy) LRange(key string, start, stop int64) redis2.StringSliceCmd {
	return p.redisClient.LRange(key, start, stop)
}

Y
Your Name 已提交
282
//LRem lRem
E
eoLinker API Management 已提交
283 284 285 286
func (p *RedisProxy) LRem(key string, count int64, value interface{}) redis2.IntCmd {
	return p.redisClient.LRem(key, count, value)
}

Y
Your Name 已提交
287
//LSet lSet
E
eoLinker API Management 已提交
288 289 290 291
func (p *RedisProxy) LSet(key string, index int64, value interface{}) redis2.StatusCmd {
	return p.redisClient.LSet(key, index, value)
}

Y
Your Name 已提交
292
//LTrim lTrim
E
eoLinker API Management 已提交
293 294 295 296
func (p *RedisProxy) LTrim(key string, start, stop int64) redis2.StatusCmd {
	return p.redisClient.LTrim(key, start, stop)
}

Y
Your Name 已提交
297
//RPop rPop
E
eoLinker API Management 已提交
298 299
func (p *RedisProxy) RPop(key string) redis2.StringCmd { return p.redisClient.RPop(key) }

Y
Your Name 已提交
300
//RPopLPush rPopLpush
E
eoLinker API Management 已提交
301 302 303 304
func (p *RedisProxy) RPopLPush(source, destination string) redis2.StringCmd {
	return p.redisClient.RPopLPush(source, destination)
}

Y
Your Name 已提交
305
//RPush rPush
E
eoLinker API Management 已提交
306
func (p *RedisProxy) RPush(key string, values ...interface{}) redis2.IntCmd {
Y
Your Name 已提交
307
	return p.redisClient.RPush(key, values...)
E
eoLinker API Management 已提交
308 309
}

Y
Your Name 已提交
310
//RPushX rPushX
E
eoLinker API Management 已提交
311 312 313 314
func (p *RedisProxy) RPushX(key string, value interface{}) redis2.IntCmd {
	return p.redisClient.RPushX(key, value)
}

Y
Your Name 已提交
315
//SAdd sAdd
E
eoLinker API Management 已提交
316
func (p *RedisProxy) SAdd(key string, members ...interface{}) redis2.IntCmd {
Y
Your Name 已提交
317
	return p.redisClient.SAdd(key, members...)
E
eoLinker API Management 已提交
318 319
}

Y
Your Name 已提交
320
//SCard sCard
E
eoLinker API Management 已提交
321 322
func (p *RedisProxy) SCard(key string) redis2.IntCmd { return p.redisClient.SCard(key) }

Y
Your Name 已提交
323
//SDiff sDiff
E
eoLinker API Management 已提交
324 325
func (p *RedisProxy) SDiff(keys ...string) redis2.StringSliceCmd { return p.redisClient.SDiff(keys...) }

Y
Your Name 已提交
326
//SDiffStore sDiffStore
E
eoLinker API Management 已提交
327
func (p *RedisProxy) SDiffStore(destination string, keys ...string) redis2.IntCmd {
Y
Your Name 已提交
328
	return p.redisClient.SDiffStore(destination, keys...)
E
eoLinker API Management 已提交
329 330
}

Y
Your Name 已提交
331
//SInter sInter
E
eoLinker API Management 已提交
332 333 334 335
func (p *RedisProxy) SInter(keys ...string) redis2.StringSliceCmd {
	return p.redisClient.SInter(keys...)
}

Y
Your Name 已提交
336
//SInterStore sInterStore
E
eoLinker API Management 已提交
337
func (p *RedisProxy) SInterStore(destination string, keys ...string) redis2.IntCmd {
Y
Your Name 已提交
338
	return p.redisClient.SInterStore(destination, keys...)
E
eoLinker API Management 已提交
339 340
}

Y
Your Name 已提交
341
//SIsMember sIsMember
E
eoLinker API Management 已提交
342 343 344 345
func (p *RedisProxy) SIsMember(key string, member interface{}) redis2.BoolCmd {
	return p.redisClient.SIsMember(key, member)
}

Y
Your Name 已提交
346
//SMembers sMembers
E
eoLinker API Management 已提交
347 348
func (p *RedisProxy) SMembers(key string) redis2.StringSliceCmd { return p.redisClient.SMembers(key) }

Y
Your Name 已提交
349
//SMembersMap sMembersMap
E
eoLinker API Management 已提交
350 351 352 353
func (p *RedisProxy) SMembersMap(key string) redis2.StringStructMapCmd {
	return p.redisClient.SMembersMap(key)
}

Y
Your Name 已提交
354
//SMove sMove
E
eoLinker API Management 已提交
355 356 357 358
func (p *RedisProxy) SMove(source, destination string, member interface{}) redis2.BoolCmd {
	return p.redisClient.SMove(source, destination, member)
}

Y
Your Name 已提交
359
//SPop sPop
E
eoLinker API Management 已提交
360 361
func (p *RedisProxy) SPop(key string) redis2.StringCmd { return p.redisClient.SPop(key) }

Y
Your Name 已提交
362
//SPopN sPopN
E
eoLinker API Management 已提交
363 364 365 366
func (p *RedisProxy) SPopN(key string, count int64) redis2.StringSliceCmd {
	return p.redisClient.SPopN(key, count)
}

Y
Your Name 已提交
367
//SRandMember sRandMember
E
eoLinker API Management 已提交
368 369
func (p *RedisProxy) SRandMember(key string) redis2.StringCmd { return p.redisClient.SRandMember(key) }

Y
Your Name 已提交
370
//SRandMemberN sRandMemberN
E
eoLinker API Management 已提交
371 372 373 374
func (p *RedisProxy) SRandMemberN(key string, count int64) redis2.StringSliceCmd {
	return p.redisClient.SRandMemberN(key, count)
}

Y
Your Name 已提交
375
//SRem sRem
E
eoLinker API Management 已提交
376
func (p *RedisProxy) SRem(key string, members ...interface{}) redis2.IntCmd {
Y
Your Name 已提交
377
	return p.redisClient.SRem(key, members...)
E
eoLinker API Management 已提交
378 379
}

Y
Your Name 已提交
380
//SUnion sUnion
E
eoLinker API Management 已提交
381 382 383 384
func (p *RedisProxy) SUnion(keys ...string) redis2.StringSliceCmd {
	return p.redisClient.SUnion(keys...)
}

Y
Your Name 已提交
385
//SUnionStore sUnionStore
E
eoLinker API Management 已提交
386
func (p *RedisProxy) SUnionStore(destination string, keys ...string) redis2.IntCmd {
Y
Your Name 已提交
387
	return p.redisClient.SUnionStore(destination, keys...)
E
eoLinker API Management 已提交
388 389
}

Y
Your Name 已提交
390
//Pipeline pipeLine
E
eoLinker API Management 已提交
391 392 393 394 395 396 397 398 399
func (p *RedisProxy) Pipeline() redis2.Pipeliner {
	pipe := p.redisClient.Pipeline()
	return &PipelineProxy{
		RedisProxy: RedisProxy{redisClient: pipe},
		pipeliner:  pipe,
	}

}

Y
Your Name 已提交
400
//Pipelined pipeLined
E
eoLinker API Management 已提交
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
func (p *RedisProxy) Pipelined(fn func(redis2.Pipeliner) error) ([]redis2.Cmder, error) {
	cmders, e := p.redisClient.Pipelined(func(pipeliner redis.Pipeliner) error {
		pip := &PipelineProxy{
			RedisProxy{pipeliner}, pipeliner,
		}
		return fn(pip)

	})
	if e != nil {
		return nil, e
	}

	cmds := make([]redis2.Cmder, 0, len(cmders))
	for _, c := range cmders {
		cmds = append(cmds, c)
	}
	return cmds, nil
}