MediaWiki REL1_33
APCBagOStuff.php
Go to the documentation of this file.
1<?php
36class APCBagOStuff extends BagOStuff {
42 const KEY_SUFFIX = ':3';
43
44 protected function doGet( $key, $flags = 0, &$casToken = null ) {
45 $casToken = null;
46
47 $blob = apc_fetch( $key . self::KEY_SUFFIX );
48 $value = $this->unserialize( $blob );
49 if ( $value !== false ) {
50 $casToken = $blob; // don't bother hashing this
51 }
52
53 return $value;
54 }
55
56 public function set( $key, $value, $exptime = 0, $flags = 0 ) {
58 $key . self::KEY_SUFFIX,
59 $this->serialize( $value ),
60 $exptime
61 );
62
63 return true;
64 }
65
66 public function add( $key, $value, $exptime = 0, $flags = 0 ) {
67 return apc_add(
68 $key . self::KEY_SUFFIX,
69 $this->serialize( $value ),
70 $exptime
71 );
72 }
73
74 public function delete( $key, $flags = 0 ) {
75 apc_delete( $key . self::KEY_SUFFIX );
76
77 return true;
78 }
79
80 public function incr( $key, $value = 1 ) {
81 return apc_inc( $key . self::KEY_SUFFIX, $value );
82 }
83
84 public function decr( $key, $value = 1 ) {
85 return apc_dec( $key . self::KEY_SUFFIX, $value );
86 }
87
88 protected function serialize( $value ) {
89 return $this->isInteger( $value ) ? (int)$value : serialize( $value );
90 }
91
92 protected function unserialize( $value ) {
93 return $this->isInteger( $value ) ? (int)$value : unserialize( $value );
94 }
95}
serialize()
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
This is a wrapper for APC's shared memory functions.
doGet( $key, $flags=0, &$casToken=null)
add( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
decr( $key, $value=1)
Decrease stored value of $key by $value while preserving its TTL.
serialize( $value)
unserialize( $value)
incr( $key, $value=1)
Increase stored value of $key by $value while preserving its TTL.
Class representing a cache/ephemeral data store.
Definition BagOStuff.php:58
isInteger( $value)
Check if a value is an integer.