//DLock lock with setnx or set px or set ex
DLock lock with setnx or set px or set ex
// DLock lock with setnx or set px or set ex
func (s *ClientSimple) DLock(ctx context.Context, key, value string, expire time.Duration) bool {
	var locked string
	var err error
	if expire == 0 {
		locked, err = redis.String(s.getConn().Do("setnx", key, value))
	} else {
		if expire < time.Second && expire%time.Second != 0 {
			locked, err = redis.String(s.getConn().Do("set", key, value, "px", int64(expire/time.Millisecond), "nx"))
		} else {
			locked, err = redis.String(s.getConn().Do("set", key, value, "ex", int64(expire/time.Second), "nx"))
		}
	}
	return nil == err && locked == "OK"
}
func ( s * ClientSimple ) DLock ( ctx context . Context , key , value string , expire time . Duration ) bool { var locked string var err error if expire == 0 { locked , err = redis . String ( s . getConn ( ) . Do ( " " , key , value ) ) } else { if expire < time . Second && expire % time . Second != 0 { locked , err = redis . String ( s . getConn ( ) . Do ( " " , key , value , " " , int64 ( expire / time . Millisecond ) , " " ) ) } else { locked , err = redis . String ( s . getConn ( ) . Do ( " " , key , value , " " , int64 ( expire / time . Second ) , " " ) ) } } return nil == err && locked == " " }
DLock lock with setnx or set px or set ex
DLock lock with setnx or set px or set ex