download:DDD (domain driven design) interpretation and excellent practice
-
The source code parsing
package redis
import ( “math/rand” “strconv” “sync/atomic” “time”
red "github.com/go-redis/redis" "github.com/tal-tech/go-zero/core/logx" Copy the code
)
const ( letters = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ” lockCommand =
if redis.call("GET", KEYS[1]) == ARGV[1] then redis.call("SET", KEYS[1], ARGV[1], "PX", ARGV[2]) return "OK" else return redis.call("SET", KEYS[1], ARGV[1], "NX", "PX", ARGV[2]) end
delCommand =if redis.call("GET", KEYS[1]) == ARGV[1] then return redis.call("DEL", KEYS[1]) else return 0 end
randomLen = 16