"Fossies" - the Fresh Open Source Software Archive

Member "serendipity/bundled-libs/voku/simple-cache/src/voku/cache/AdapterXcache.php" (20 Nov 2022, 1565 Bytes) of package /linux/www/serendipity-2.4.0.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AdapterXcache.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.3.5_vs_2.4.0.

    1 <?php
    2 
    3 declare(strict_types=1);
    4 
    5 namespace voku\cache;
    6 
    7 /**
    8  * AdapterXcache: Xcache-adapter
    9  */
   10 class AdapterXcache implements iAdapter
   11 {
   12     /**
   13      * @var bool
   14      */
   15     public $installed = false;
   16 
   17     /**
   18      * __construct
   19      */
   20     public function __construct()
   21     {
   22         if (\extension_loaded('xcache') === true) {
   23             $this->installed = true;
   24         }
   25     }
   26 
   27     /**
   28      * {@inheritdoc}
   29      */
   30     public function exists(string $key): bool
   31     {
   32         return \xcache_isset($key);
   33     }
   34 
   35     /**
   36      * {@inheritdoc}
   37      */
   38     public function get(string $key)
   39     {
   40         return \xcache_get($key);
   41     }
   42 
   43     /**
   44      * {@inheritdoc}
   45      */
   46     public function installed(): bool
   47     {
   48         return $this->installed;
   49     }
   50 
   51     /**
   52      * {@inheritdoc}
   53      */
   54     public function remove(string $key): bool
   55     {
   56         return \xcache_unset($key);
   57     }
   58 
   59     /**
   60      * {@inheritdoc}
   61      */
   62     public function removeAll(): bool
   63     {
   64         if (\defined('XC_TYPE_VAR')) {
   65             $xCacheCount = xcache_count(XC_TYPE_VAR);
   66             for ($i = 0; $i < $xCacheCount; $i++) {
   67                 \xcache_clear_cache(XC_TYPE_VAR, $i);
   68             }
   69 
   70             return true;
   71         }
   72 
   73         return false;
   74     }
   75 
   76     /**
   77      * {@inheritdoc}
   78      */
   79     public function set(string $key, $value): bool
   80     {
   81         return \xcache_set($key, $value);
   82     }
   83 
   84     /**
   85      * {@inheritdoc}
   86      */
   87     public function setExpired(string $key, $value, int $ttl = 0): bool
   88     {
   89         return \xcache_set($key, $value, $ttl);
   90     }
   91 }