作者 邓超

redis add

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