Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getLastWriteTime()
 {
     if (!$this->exists()) {
         return time();
     }
     return apcu_fetch($this->storeId . '.lastmod');
 }
Example #2
0
 public function fetch($key, $default = '')
 {
     if (!apcu_exists($this->hash($key))) {
         return $default;
     }
     return apcu_fetch($this->hash($key));
 }
Example #3
0
 /**
  * {@inheritdoc}
  *
  * @return void
  */
 public function get($key)
 {
     if ($this->apcu) {
         return apcu_fetch($key);
     }
     return apc_fetch($key);
 }
Example #4
0
function shortcode_ldjam($atts)
{
    ld_get_vars();
    // Populate the $ldvar global //
    global $ldvar;
    // Verify URL //
    if (isset($_GET['u'])) {
        $url = to_slug($_GET['u']);
        if ($url !== $_GET['u']) {
            $_GET['u'] = $url;
            $link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REDIRECT_URL']}";
            $link = htmlspecialchars($link, ENT_QUOTES, 'UTF-8');
            $link .= "?" . http_build_query($_GET);
            $link = str_replace('%2F', '/', $link);
            // Replace % code for / with an actual slash //
            ld_redirect($link);
        }
    }
    $id = null;
    // Verify ID //
    if (isset($_GET['i'])) {
        $id = base_decode(base_fix($_GET['i']));
    }
    //	ld_redirect
    //	print_r($_GET);
    //	echo( to_slug($_GET['u']) );
    $shimmy = apcu_fetch('shimmy');
    echo $_GET['u'];
    echo " | " . $id;
    echo " | " . base_encode($id);
    //print_r($_SERVER);
    return "<br />I am very important";
}
 /**
  * Test purging the apcu cache store.
  */
 public function test_purge()
 {
     if (!cachestore_apcu::are_requirements_met()) {
         $this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.');
     }
     $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test');
     $instance = cachestore_apcu::initialise_unit_test_instance($definition);
     // Test a simple purge return.
     $this->assertTrue($instance->purge());
     // Test purge works.
     $this->assertTrue($instance->set('test', 'monster'));
     $this->assertSame('monster', $instance->get('test'));
     $this->assertTrue($instance->purge());
     $this->assertFalse($instance->get('test'));
     // Test purge with custom data.
     $this->assertTrue($instance->set('test', 'monster'));
     $this->assertSame('monster', $instance->get('test'));
     $this->assertTrue(apcu_store('test', 'pirate', 180));
     $this->assertSame('monster', $instance->get('test'));
     $this->assertTrue(apcu_exists('test'));
     $this->assertSame('pirate', apcu_fetch('test'));
     // Purge and check that our data is gone but the the custom data is still there.
     $this->assertTrue($instance->purge());
     $this->assertFalse($instance->get('test'));
     $this->assertTrue(apcu_exists('test'));
     $this->assertSame('pirate', apcu_fetch('test'));
 }
Example #6
0
 public function read()
 {
     if (!apcu_exists($this->key)) {
         return array('_global' => array());
     }
     return apcu_fetch($this->key);
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     if ($this->driver == self::APCU_DRIVER) {
         return apcu_fetch($this->prefix . $name);
     }
     return apc_fetch($this->prefix . $name);
 }
Example #8
0
 public function fetch($key)
 {
     if (apcu_exists($key)) {
         return apcu_fetch($key);
     }
     return false;
 }
 public function testConstructor()
 {
     $loader = new ClassLoader();
     $loader->addPrefix('Apc\\Namespaced', __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures');
     $loader = new ApcClassLoader('test.prefix.', $loader);
     $this->assertEquals($loader->findFile('\\Apc\\Namespaced\\FooBar'), apcu_fetch('test.prefix.\\Apc\\Namespaced\\FooBar'), '__construct() takes a prefix as its first argument');
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 protected function getArrayDataFromStorage(array $keys)
 {
     $result = apcu_fetch($keys);
     if ($result === false) {
         return [];
     }
     return $result;
 }
Example #11
0
 public function get($name)
 {
     if ($this->hasAPCu) {
         return apcu_fetch($name);
     } else {
         return $_SESSION[$name];
     }
 }
Example #12
0
 public static function getBlacklist()
 {
     $blacklist = apcu_fetch(self::$prefix . self::BLACKLIST_KEY);
     if (empty($blacklist)) {
         return [];
     }
     return $blacklist;
 }
Example #13
0
 /**
  * Get.
  * @param  string $key
  * @param  any    $valueDefault
  * @return any
  */
 public final function get(string $key, $valueDefault = null)
 {
     $value = apcu_fetch($key, $ok);
     if (!$ok) {
         $value = $valueDefault;
     }
     return $value;
 }
Example #14
0
 public function get($key)
 {
     $result = apcu_fetch($this->getPrefix() . $key, $success);
     if (!$success) {
         return null;
     }
     return $result;
 }
Example #15
0
 /**
  * Returns the value of a cache entry from its key
  *
  * @api
  *
  * @param  string    $key the key of the cache entry
  * @return mixed the value of the entry, as it was passed to CacheInterface::set, null if not present in cache
  */
 public function get($key)
 {
     $value = \apcu_fetch($key, $success);
     if (!$success) {
         return null;
     }
     return $value;
 }
Example #16
0
 /**
  * apcu library 5.x for php 7 have no more functions apc_*
  * Uses apcu_* instead
  */
 public static function apc_fetch($cacheKey)
 {
     if (self::isPhp7()) {
         return apcu_fetch($cacheKey);
     } else {
         return apc_fetch($cacheKey);
     }
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 protected function doFetch(array $ids)
 {
     try {
         return apcu_fetch($ids);
     } catch (\Error $e) {
         throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
     }
 }
Example #18
0
 public function routing($request)
 {
     $group = null;
     $route = null;
     $path = trim($request->path, '/');
     $cacheKey = "route_cached_" . $request->host . '_' . base64_encode($path);
     if ($route = \apcu_fetch($cacheKey)) {
         return $route;
     }
     if ($path == null) {
         $path = "/";
     }
     if (!($group = $this->getGroupByDomain($request->host))) {
         if ($path == null && $this->_default_group) {
             $group = $this->_default_group;
         } else {
             $tmp = explode('/', $path);
             $directory = $tmp[0];
             if ($group = $this->getGroupByDirectory($directory)) {
                 unset($tmp[0]);
                 $path = implode('/', $tmp);
             } elseif ($this->_default_group) {
                 //                    $group = $this->_default_group;
             }
             unset($tmp);
         }
     }
     //打补丁 如果没有匹配, 取所有路由循环
     if ($this->_groups && !$group) {
         foreach ($this->_groups as $v) {
             $route = $v->match($path);
             if ($route) {
                 $group = $v;
                 break;
             }
         }
     }
     $group = $group ? $group : $this->_default_group;
     $route = $route ? $route : ($group ? $group->match($path) : null);
     if ($group && $route) {
     } else {
         $route = $this->getRouteByPath($path);
         $route->setPrefix($group->getPrefix());
         //传递所有前缀
         $allPrefix = [];
         if ($this->_groups) {
             foreach ($this->_groups as $k => $v) {
                 $allPrefix[] = $k;
             }
         }
         $route->setAllPrefix($allPrefix);
     }
     if ($route !== null) {
         \apcu_add($cacheKey, $route, 3600);
         return $route;
     }
     return false;
 }
Example #19
0
 /**
  * Get the value matching the specified key.
  * @see apc_fetch()
  *
  * @param mixed $key
  *
  * @return boolean|string
  */
 public function get($key)
 {
     if (function_exists('apcu_fetch')) {
         return apcu_fetch($key);
     } elseif (function_exists('apc_fetch')) {
         return apc_fetch($key);
     }
     return false;
 }
Example #20
0
 public function get($key)
 {
     $return = apcu_fetch($key, $success);
     if ($success !== false) {
         return $return;
     } else {
         return is_array($key) ? array() : false;
     }
 }
Example #21
0
 /**
  * retrieve the value specified by the $key from the cache if it exists, null otherwise.
  *
  * @param string $key
  *
  * @return mixed
  */
 public function retrieve($key)
 {
     $key = strval($key);
     if ($this->exists($key) == false) {
         return null;
     }
     $value = apcu_fetch($key);
     return $value;
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function get($key)
 {
     $success = null;
     $result = apcu_fetch($key, $success);
     if (!$success) {
         return null;
     }
     return $result;
 }
Example #23
0
 public static function fetch($k)
 {
     if (function_exists('apc_fetch')) {
         return apc_fetch($k);
     } elseif (function_exists('apcu_fetch')) {
         return apcu_fetch($k);
     }
     return false;
 }
Example #24
0
 public function getHandlers()
 {
     $key = $this->_mapTags($this->_handlers_name, 0);
     if (apcu_exists($key)) {
         $result = apcu_fetch($key);
         return $result;
     }
     return array();
 }
Example #25
0
 /**
  * {@inheritdoc}
  */
 protected function fetchObjectFromCache($key)
 {
     if ($this->skipIfCli()) {
         return [false, null, []];
     }
     $success = false;
     $data = apcu_fetch($key, $success);
     return [$success, $data, []];
 }
Example #26
0
 /**
  * @inheritdoc
  */
 public function removeFromList($listName, $value)
 {
     $list = apcu_fetch($listName) ?: [];
     foreach ($list as $key => $listValue) {
         if ($listValue == $value) {
             unset($list[$key]);
         }
     }
     return $this->set($listName, $list);
 }
Example #27
0
 /**
  * @inheritdoc
  */
 public function get($key, $fields)
 {
     if (is_string($fields)) {
         return apcu_fetch($this->getKeyByField($key, $fields));
     }
     $result = array_map(function ($field) use($key) {
         return apcu_fetch($this->getKeyByField($key, $field));
     }, $fields);
     return array_combine($fields, array_values($result));
 }
Example #28
0
 /**
  * @return array
  */
 public static function getAll()
 {
     $className = md5('const' . __CLASS__);
     if (self::cacheHas($className)) {
         return apcu_fetch($className);
     }
     $constants = self::getConstants();
     self::cacheStore($className, $constants);
     return $constants;
 }
Example #29
0
 public function __construct($id, $url)
 {
     $this->content = apcu_fetch('cachecontrol_' . $id);
     if (!$this->content || isset($_GET['nocache'])) {
         $api = new Github\Api();
         $response = $api->get($url);
         $this->content = $api->decode($response);
         apcu_store('cachecontrol_' . $id, $this->content, 300);
     }
 }
Example #30
0
 /**
  * Fetch the result of a previous invocation from APC or APCu.
  *
  * @param string $key
  * @param bool &$success
  */
 protected function fetchResult($key, &$success)
 {
     $success = false;
     if (function_exists('apc_fetch')) {
         return apc_fetch($key, $success);
     } elseif (function_exists('apcu_fetch')) {
         return apcu_fetch($key, $success);
     }
     return false;
 }