45 const KEY_SUFFIX =
':4';
48 $params[
'segmentationSize'] = $params[
'segmentationSize'] ?? INF;
49 parent::__construct( $params );
51 $this->nativeSerialize = ( ini_get(
'apc.serializer' ) !==
'default' );
54 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
57 $blob = apcu_fetch( $key . self::KEY_SUFFIX );
59 if ( $value !==
false ) {
66 protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
68 $key . self::KEY_SUFFIX,
69 $this->nativeSerialize ? $value : $this->
serialize( $value ),
74 protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
76 $key . self::KEY_SUFFIX,
77 $this->nativeSerialize ? $value : $this->
serialize( $value ),
82 protected function doDelete( $key, $flags = 0 ) {
83 apcu_delete( $key . self::KEY_SUFFIX );
88 public function incr( $key, $value = 1, $flags = 0 ) {
90 if ( apcu_exists( $key . self::KEY_SUFFIX ) ) {
91 return apcu_inc( $key . self::KEY_SUFFIX, $value );
97 public function decr( $key, $value = 1, $flags = 0 ) {
99 if ( apcu_exists( $key . self::KEY_SUFFIX ) ) {
100 return apcu_dec( $key . self::KEY_SUFFIX, $value );
This is a wrapper for APCU's shared memory functions.
doAdd( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
decr( $key, $value=1, $flags=0)
Decrease stored value of $key by $value while preserving its TTL.
doSet( $key, $value, $exptime=0, $flags=0)
Set an item.
doDelete( $key, $flags=0)
Delete an item.
bool $nativeSerialize
Whether to trust the APC implementation to serialization.
__construct(array $params=[])
doGet( $key, $flags=0, &$casToken=null)
incr( $key, $value=1, $flags=0)
Increase stored value of $key by $value while preserving its TTL.
Storage medium specific cache for storing items (e.g.