-
Notifications
You must be signed in to change notification settings - Fork 1
/
flushDBTemplet.go
46 lines (40 loc) · 1.06 KB
/
flushDBTemplet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package src
import (
goredis "github.com/adimax2953/go-redis"
logtool "github.com/adimax2953/log-tool"
)
// FlushDB function - keys, args[] string - return string , error
func (s *MyScriptor) FlushDB(keys []string) (string, error) {
res, err := s.Scriptor.ExecSha(FlushDBID, keys)
if err != nil {
logtool.LogError("FlushDB ExecSha Error", err)
return "", err
}
result := &RedisResult{}
reader := goredis.NewRedisArrayReplyReader(res.([]interface{}))
result.Value = reader.ReadString()
if result.Value == "" {
logtool.LogError("FlushDB Value Is Nil")
return "", err
}
return result.Value, nil
}
// FlushDB - 清空指定DB
const (
FlushDBID = "FlushDB"
FlushDBTemplate = `
--[[
Author : Adimax.Tsai
Description : FlushDB
EVALSHA <script_sha1> 0 {DBKey}
--]]
local DBKey = tonumber(KEYS[1])
local sender = "FlushDB.lua"
if DBKey then
redis.call("select",DBKey)
local r1= ""
r1 = redis.call('flushdb')
return { r1 }
end
`
)