/**
  * Constructor.
  *
  * Available parameters are:
  *   - servers:             The list of IP:port combinations holding the memcached servers.
  *   - debug:               Whether to set the debug flag in the underlying client.
  *   - persistent:          Whether to use a persistent connection
  *   - compress_threshold:  The minimum size an object must be before it is compressed
  *   - timeout:             The read timeout in microseconds
  *   - connect_timeout:     The connect timeout in seconds
  *
  * @param array $params
  */
 function __construct($params)
 {
     parent::__construct($params);
     $params = $this->applyDefaultParams($params);
     $this->client = new MemCachedClientforWiki($params);
     $this->client->set_servers($params['servers']);
     $this->client->set_debug($params['debug']);
 }
Esempio n. 2
0
 /**
  * @param MemcachedBagOStuff $memc
  * @param array $keys List of acquired keys
  */
 protected function releaseMutexes(MemcachedBagOStuff $memc, array $keys)
 {
     foreach ($keys as $key) {
         $memc->delete("{$key}:mutex");
     }
 }
 public function add($key, $value, $exptime = 0)
 {
     $this->debugLog("add({$key})");
     return $this->checkResult($key, parent::add($key, $value, $exptime));
 }
 /**
  * @param $key string
  * @param $value int
  * @param $exptime
  * @return Mixed
  */
 public function replace($key, $value, $exptime = 0)
 {
     $this->debugLog("replace({$key})");
     return $this->checkResult($key, parent::replace($key, $value, $exptime));
 }
 /**
  * @covers MemcachedBagOStuff::makeKeyInternal
  */
 public function testKeyNormalization()
 {
     $this->assertEquals('test:vanilla', $this->cache->makeKey('vanilla'));
     $this->assertEquals('test:punctuation_marks_are_ok:!@$^&*()', $this->cache->makeKey('punctuation_marks_are_ok', '!@$^&*()'));
     $this->assertEquals('test:but_spaces:hashes%23:and%0Anewlines:are_not', $this->cache->makeKey('but spaces', 'hashes#', "and\nnewlines", 'are_not'));
     $this->assertEquals('test:this:key:contains:%F0%9D%95%9E%F0%9D%95%A6%F0%9D%95%9D%F0%9D%95%A5%F0%9' . 'D%95%9A%F0%9D%95%93%F0%9D%95%AA%F0%9D%95%A5%F0%9D%95%96:characters', $this->cache->makeKey('this', 'key', 'contains', '๐•ž๐•ฆ๐•๐•ฅ๐•š๐•“๐•ช๐•ฅ๐•–', 'characters'));
     $this->assertEquals('test:this:key:contains:#c118f92685a635cb843039de50014c9c', $this->cache->makeKey('this', 'key', 'contains', '๐•ฅ๐• ๐•  ๐•ž๐•’๐•Ÿ๐•ช ๐•ž๐•ฆ๐•๐•ฅ๐•š๐•“๐•ช๐•ฅ๐•– ๐•”๐•™๐•’๐•ฃ๐•’๐•”๐•ฅ๐•–๐•ฃ๐•ค'));
     $this->assertEquals('test:##5820ad1d105aa4dc698585c39df73e19', $this->cache->makeKey('๐•–๐•ง๐•–๐•Ÿ', '๐•š๐•—', '๐•จ๐•–', '๐•„๐”ป๐Ÿ', '๐•–๐•’๐•”๐•™', '๐•’๐•ฃ๐•˜๐•ฆ๐•ž๐•–๐•Ÿ๐•ฅ', '๐•ฅ๐•™๐•š๐•ค', '๐•œ๐•–๐•ช', '๐•จ๐• ๐•ฆ๐•๐••', '๐•ค๐•ฅ๐•š๐•๐•', '๐•“๐•–', '๐•ฅ๐• ๐• ', '๐•๐• ๐•Ÿ๐•˜'));
     $this->assertEquals('test:%23%235820ad1d105aa4dc698585c39df73e19', $this->cache->makeKey('##5820ad1d105aa4dc698585c39df73e19'));
     $this->assertEquals('test:percent_is_escaped:!@$%25^&*()', $this->cache->makeKey('percent_is_escaped', '!@$%^&*()'));
     $this->assertEquals('test:colon_is_escaped:!@$%3A^&*()', $this->cache->makeKey('colon_is_escaped', '!@$:^&*()'));
     $this->assertEquals('test:long_key_part_hashed:#0244f7b1811d982dd932dd7de01465ac', $this->cache->makeKey('long_key_part_hashed', str_repeat('y', 500)));
 }