Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
apcu
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 4
42
0.00% covered (danger)
0.00%
0 / 1
 purge
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 _read
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 _write
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 _delete
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\cache\driver;
15
16/**
17* ACM for APCU
18*/
19class apcu extends \phpbb\cache\driver\memory
20{
21    var $extension = 'apcu';
22
23    /**
24    * {@inheritDoc}
25    */
26    function purge()
27    {
28        if (PHP_SAPI !== 'cli' || @ini_get('apc.enable_cli'))
29        {
30            /*
31             * Use an iterator to selectively delete our cache entries without disturbing
32             * any other cache users (e.g. other phpBB boards hosted on this server)
33             */
34            apcu_delete(new \APCUIterator('#^' . $this->key_prefix . '#'));
35        }
36
37        parent::purge();
38    }
39
40    /**
41    * {@inheritDoc}
42    */
43    protected function _read(string $var)
44    {
45        return apcu_fetch($this->key_prefix . $var);
46    }
47
48    /**
49    * {@inheritDoc}
50    */
51    protected function _write(string $var, $data, int $ttl = 2592000): bool
52    {
53        return apcu_store($this->key_prefix . $var, $data, $ttl);
54    }
55
56    /**
57     * {@inheritDoc}
58     */
59    protected function _delete(string $var): bool
60    {
61        return apcu_delete($this->key_prefix . $var);
62    }
63}