MediaWiki  1.34.0
APCBagOStuff.php
Go to the documentation of this file.
1 <?php
39 
45  const KEY_SUFFIX = ':4';
46 
47  public function __construct( array $params = [] ) {
48  $params['segmentationSize'] = $params['segmentationSize'] ?? INF;
49  parent::__construct( $params );
50  // The extension serializer is still buggy, unlike "php" and "igbinary"
51  $this->nativeSerialize = ( ini_get( 'apc.serializer' ) !== 'default' );
52  }
53 
54  protected function doGet( $key, $flags = 0, &$casToken = null ) {
55  $casToken = null;
56 
57  $blob = apc_fetch( $key . self::KEY_SUFFIX );
58  $value = $this->nativeSerialize ? $blob : $this->unserialize( $blob );
59  if ( $value !== false ) {
60  $casToken = $blob; // don't bother hashing this
61  }
62 
63  return $value;
64  }
65 
66  protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
67  apc_store(
68  $key . self::KEY_SUFFIX,
69  $this->nativeSerialize ? $value : $this->serialize( $value ),
70  $exptime
71  );
72 
73  return true;
74  }
75 
76  protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
77  return apc_add(
78  $key . self::KEY_SUFFIX,
79  $this->nativeSerialize ? $value : $this->serialize( $value ),
80  $exptime
81  );
82  }
83 
84  protected function doDelete( $key, $flags = 0 ) {
85  apc_delete( $key . self::KEY_SUFFIX );
86 
87  return true;
88  }
89 
90  public function incr( $key, $value = 1, $flags = 0 ) {
91  return apc_inc( $key . self::KEY_SUFFIX, $value );
92  }
93 
94  public function decr( $key, $value = 1, $flags = 0 ) {
95  return apc_dec( $key . self::KEY_SUFFIX, $value );
96  }
97 }
APCBagOStuff\doDelete
doDelete( $key, $flags=0)
Delete an item.
Definition: APCBagOStuff.php:84
APCBagOStuff\decr
decr( $key, $value=1, $flags=0)
Decrease stored value of $key by $value while preserving its TTL.
Definition: APCBagOStuff.php:94
MediumSpecificBagOStuff\serialize
serialize( $value)
Definition: MediumSpecificBagOStuff.php:941
APCBagOStuff\doGet
doGet( $key, $flags=0, &$casToken=null)
Definition: APCBagOStuff.php:54
$blob
$blob
Definition: testCompression.php:65
APCBagOStuff\__construct
__construct(array $params=[])
Definition: APCBagOStuff.php:47
APCBagOStuff\$nativeSerialize
bool $nativeSerialize
Whether to trust the APC implementation to serialization.
Definition: APCBagOStuff.php:38
APCBagOStuff\incr
incr( $key, $value=1, $flags=0)
Increase stored value of $key by $value while preserving its TTL.
Definition: APCBagOStuff.php:90
APCBagOStuff\doSet
doSet( $key, $value, $exptime=0, $flags=0)
Set an item.
Definition: APCBagOStuff.php:66
MediumSpecificBagOStuff
Storage medium specific cache for storing items (e.g.
Definition: MediumSpecificBagOStuff.php:34
APCBagOStuff\doAdd
doAdd( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
Definition: APCBagOStuff.php:76
MediumSpecificBagOStuff\unserialize
unserialize( $value)
Definition: MediumSpecificBagOStuff.php:950
APCBagOStuff
This is a wrapper for APC's shared memory functions.
Definition: APCBagOStuff.php:36