35 parent::__construct( $params );
39 'compress_threshold' => 1500,
40 'connect_timeout' => 0.5,
45 $this->client->set_servers( $params[
'servers'] );
46 $this->client->set_debug(
true );
50 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
58 ? $this->client->get( $routeKey, $casToken ) : $this->client->get( $routeKey );
68 protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
71 $res = $this->client->set( $routeKey, $value, $this->
fixExpiry( $exptime ) );
81 protected function doDelete( $key, $flags = 0 ) {
84 $res = $this->client->delete( $routeKey );
94 protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
97 $res = $this->client->add( $routeKey, $value, $this->
fixExpiry( $exptime ) );
107 protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
110 $res = $this->client->cas( $casToken, $routeKey, $value, $this->
fixExpiry( $exptime ) );
123 $this->client->add( $routeKey, $init - $step, $this->
fixExpiry( $exptime ) );
124 $this->client->incr( $routeKey, $step );
134 $newValue = $this->client->incr( $routeKey, $step ) ??
false;
135 if ( $newValue ===
false && !$this->
getLastError( $watchPoint ) ) {
138 $newValue =
$success ? $init :
false;
139 if ( $newValue ===
false && !$this->
getLastError( $watchPoint ) ) {
141 $newValue = $this->client->incr( $routeKey, $step ) ??
false;
152 $res = $this->client->touch( $routeKey, $this->
fixExpiry( $exptime ) );
164 foreach ( $keys as $key ) {
168 $resByRouteKey = $this->client->get_multi( $routeKeys );
171 foreach ( $resByRouteKey as $routeKey => $value ) {
184 return is_int( $value ) ? $value : $this->client->serialize( $value );
189 return $this->
isInteger( $value ) ? (int)$value : $this->client->unserialize( $value );
194class_alias( MemcachedPhpBagOStuff::class,
'MemcachedPhpBagOStuff' );
memcached client class implemented using (p)fsockopen()