53 'compress_threshold' => 1500,
54 'connect_timeout' => 0.5,
59 $this->client->set_servers(
$params[
'servers'] );
60 $this->client->set_debug(
true );
63 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
71 ? $this->client->get( $routeKey, $casToken ) : $this->client->get( $routeKey );
73 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
80 protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
83 $res = $this->client->set( $routeKey, $value, $this->
fixExpiry( $exptime ) );
85 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
92 protected function doDelete( $key, $flags = 0 ) {
95 $res = $this->client->delete( $routeKey );
97 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
104 protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
107 $res = $this->client->add( $routeKey, $value, $this->
fixExpiry( $exptime ) );
109 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
116 protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
119 $res = $this->client->cas( $casToken, $routeKey, $value, $this->
fixExpiry( $exptime ) );
121 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
131 $this->client->add( $routeKey, $init - $step, $this->
fixExpiry( $exptime ) );
132 $this->client->incr( $routeKey, $step );
141 $newValue = $this->client->incr( $routeKey, $step ) ??
false;
142 if ( $newValue ===
false && !$this->
getLastError( $watchPoint ) ) {
145 $newValue =
$success ? $init :
false;
146 if ( $newValue ===
false && !$this->
getLastError( $watchPoint ) ) {
148 $newValue = $this->client->incr( $routeKey, $step ) ??
false;
158 $res = $this->client->touch( $routeKey, $this->
fixExpiry( $exptime ) );
160 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
169 foreach ( $keys as $key ) {
173 $resByRouteKey = $this->client->get_multi( $routeKeys );
176 foreach ( $resByRouteKey as $routeKey => $value ) {
180 if ( $this->client->_last_cmd_status !== self::ERR_NONE ) {
188 return is_int( $value ) ? $value : $this->client->serialize( $value );
192 return $this->
isInteger( $value ) ? (int)$value : $this->client->unserialize( $value );
197class_alias( MemcachedPhpBagOStuff::class,
'MemcachedPhpBagOStuff' );
array $params
The job parameters.
memcached client class implemented using (p)fsockopen()