52 'compress_threshold' => 1500,
53 'connect_timeout' => 0.5,
58 $this->client->set_servers(
$params[
'servers'] );
59 $this->client->set_debug(
true );
62 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
70 ? $this->client->get( $routeKey, $casToken ) : $this->client->get( $routeKey );
72 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
79 protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
82 $res = $this->client->set( $routeKey, $value, $this->
fixExpiry( $exptime ) );
84 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
91 protected function doDelete( $key, $flags = 0 ) {
94 $res = $this->client->delete( $routeKey );
96 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
103 protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
106 $res = $this->client->add( $routeKey, $value, $this->
fixExpiry( $exptime ) );
108 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
115 protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
118 $res = $this->client->cas( $casToken, $routeKey, $value, $this->
fixExpiry( $exptime ) );
120 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
130 $this->client->add( $routeKey, $init - $step, $this->
fixExpiry( $exptime ) );
131 $this->client->incr( $routeKey, $step );
140 $newValue = $this->client->incr( $routeKey, $step ) ??
false;
141 if ( $newValue ===
false && !$this->
getLastError( $watchPoint ) ) {
144 $newValue =
$success ? $init :
false;
145 if ( $newValue ===
false && !$this->
getLastError( $watchPoint ) ) {
147 $newValue = $this->client->incr( $routeKey, $step ) ??
false;
157 $res = $this->client->touch( $routeKey, $this->
fixExpiry( $exptime ) );
159 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
168 foreach ( $keys as $key ) {
172 $resByRouteKey = $this->client->get_multi( $routeKeys );
175 foreach ( $resByRouteKey as $routeKey => $value ) {
179 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
187 return is_int( $value ) ? $value : $this->client->serialize( $value );
191 return $this->
isInteger( $value ) ? (int)$value : $this->client->unserialize( $value );
196class_alias( MemcachedPhpBagOStuff::class,
'MemcachedPhpBagOStuff' );
array $params
The job parameters.
memcached client class implemented using (p)fsockopen()