作者 邓超

redis add

... ... @@ -121,7 +121,7 @@ trait RedisQuery {
*/
public function add($key,$val,$ttl=null):mixed {
return $this->getClient()->eval(
"return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])",
"return redis.call('set', KEYS[1], ARGV[1], 'EX', ARGV[2], 'NX')",
[$key, $this->serialize($val), $ttl],
1
);
... ...