return $result;
}
-
-
public function add( $key, $value, $expiry = 0 ) {
list( $server, $conn ) = $this->getConnection( $key );
if ( $expiry ) {
$conn->multi();
$conn->setnx( $key, $this->serialize( $value ) );
+ // @FIXME: this always bumps the TTL; use Redis 2.8 or Lua
$conn->expire( $key, $expiry );
$result = ( $conn->exec() == array( true, true ) );
} else {
return null;
}
try {
+ // @FIXME: on races, the key may have a 0 TTL
$result = $conn->incrBy( $key, $value );
} catch ( RedisException $e ) {
$result = false;