MediaWiki  1.23.2
MemcachedBagOStuff.php
Go to the documentation of this file.
1 <?php
30  protected $client;
31 
36  protected function applyDefaultParams( $params ) {
37  if ( !isset( $params['servers'] ) ) {
38  $params['servers'] = $GLOBALS['wgMemCachedServers'];
39  }
40  if ( !isset( $params['debug'] ) ) {
41  $params['debug'] = $GLOBALS['wgMemCachedDebug'];
42  }
43  if ( !isset( $params['persistent'] ) ) {
44  $params['persistent'] = $GLOBALS['wgMemCachedPersistent'];
45  }
46  if ( !isset( $params['compress_threshold'] ) ) {
47  $params['compress_threshold'] = 1500;
48  }
49  if ( !isset( $params['timeout'] ) ) {
50  $params['timeout'] = $GLOBALS['wgMemCachedTimeout'];
51  }
52  if ( !isset( $params['connect_timeout'] ) ) {
53  $params['connect_timeout'] = 0.5;
54  }
55  return $params;
56  }
57 
63  public function get( $key, &$casToken = null ) {
64  return $this->client->get( $this->encodeKey( $key ), $casToken );
65  }
66 
73  public function set( $key, $value, $exptime = 0 ) {
74  return $this->client->set( $this->encodeKey( $key ), $value,
75  $this->fixExpiry( $exptime ) );
76  }
77 
85  public function cas( $casToken, $key, $value, $exptime = 0 ) {
86  return $this->client->cas( $casToken, $this->encodeKey( $key ),
87  $value, $this->fixExpiry( $exptime ) );
88  }
89 
95  public function delete( $key, $time = 0 ) {
96  return $this->client->delete( $this->encodeKey( $key ), $time );
97  }
98 
105  public function add( $key, $value, $exptime = 0 ) {
106  return $this->client->add( $this->encodeKey( $key ), $value,
107  $this->fixExpiry( $exptime ) );
108  }
109 
114  public function getClient() {
115  return $this->client;
116  }
117 
128  public function encodeKey( $key ) {
129  return preg_replace_callback( '/[\x00-\x20\x25\x7f]+/',
130  array( $this, 'encodeKeyCallback' ), $key );
131  }
132 
137  protected function encodeKeyCallback( $m ) {
138  return rawurlencode( $m[0] );
139  }
140 
148  function fixExpiry( $expiry ) {
149  if ( $expiry > 2592000 && $expiry < 1000000000 ) {
150  $expiry = 2592000;
151  }
152  return $expiry;
153  }
154 
163  public function decodeKey( $key ) {
164  return urldecode( $key );
165  }
166 
170  protected function debugLog( $text ) {
171  wfDebugLog( 'memcached', $text );
172  }
173 }
MemcachedBagOStuff\fixExpiry
fixExpiry( $expiry)
TTLs higher than 30 days will be detected as absolute TTLs (UNIX timestamps), and will result in the ...
Definition: MemcachedBagOStuff.php:148
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MemcachedBagOStuff\decodeKey
decodeKey( $key)
Decode a key encoded with encodeKey().
Definition: MemcachedBagOStuff.php:163
MemcachedBagOStuff
Base class for memcached clients.
Definition: MemcachedBagOStuff.php:29
MemcachedBagOStuff\applyDefaultParams
applyDefaultParams( $params)
Fill in the defaults for any parameters missing from $params, using the backwards-compatible global v...
Definition: MemcachedBagOStuff.php:36
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1040
$params
$params
Definition: styleTest.css.php:40
BagOStuff
interface is intended to be more or less compatible with the PHP memcached client.
Definition: BagOStuff.php:43
MemcachedBagOStuff\debugLog
debugLog( $text)
Send a debug message to the log.
Definition: MemcachedBagOStuff.php:170
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
MemcachedBagOStuff\cas
cas( $casToken, $key, $value, $exptime=0)
Definition: MemcachedBagOStuff.php:85
MemcachedBagOStuff\encodeKey
encodeKey( $key)
Encode a key for use on the wire inside the memcached protocol.
Definition: MemcachedBagOStuff.php:128
$value
$value
Definition: styleTest.css.php:45
MemcachedBagOStuff\$client
$client
Definition: MemcachedBagOStuff.php:30
MemcachedBagOStuff\getClient
getClient()
Get the underlying client object.
Definition: MemcachedBagOStuff.php:114
MemcachedBagOStuff\add
add( $key, $value, $exptime=0)
Definition: MemcachedBagOStuff.php:105
MemcachedBagOStuff\encodeKeyCallback
encodeKeyCallback( $m)
Definition: MemcachedBagOStuff.php:137
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6