diff options
author | v12mike <github@ingenious.co.nz> | 2018-07-15 21:50:18 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2018-09-16 16:05:22 +0200 |
commit | 02234783c6f0fd9b15faf7a17d3bb8b1d39da557 (patch) | |
tree | 64f3098bdc313cc83d9b2367643f881c4203ad31 /tests/cache | |
parent | 04899d1efd261493111e309600531d363b73bc46 (diff) | |
download | forums-02234783c6f0fd9b15faf7a17d3bb8b1d39da557.tar forums-02234783c6f0fd9b15faf7a17d3bb8b1d39da557.tar.gz forums-02234783c6f0fd9b15faf7a17d3bb8b1d39da557.tar.bz2 forums-02234783c6f0fd9b15faf7a17d3bb8b1d39da557.tar.xz forums-02234783c6f0fd9b15faf7a17d3bb8b1d39da557.zip |
[ticket/15726] Implement selective purge in APCu cache driver
The current APCu cache driver implements a global clearing of the APCu
when the phpBB cache is purged. This is inappropriate if there are other
phpBB boards, or other php applications sharing the APCu cache.
This patch changes the behviour so that only cache entries matching
the key_prefix of this board are cleared by a phpBB cache purge.
The APCu unit test script has been updated to test this behaviour.
It has also been updated so that the test case can be run individually
previously it relied on initialisations made in other test scripts.
PHPBB3-15726
Diffstat (limited to 'tests/cache')
-rwxr-xr-x[-rw-r--r--] | tests/cache/apcu_driver_test.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php index 9de1d82a15..2002fb66d8 100644..100755 --- a/tests/cache/apcu_driver_test.php +++ b/tests/cache/apcu_driver_test.php @@ -49,10 +49,27 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case protected function setUp() { + global $phpbb_container, $phpbb_root_path; + parent::setUp(); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); + $this->driver = new \phpbb\cache\driver\apcu; $this->driver->purge(); } + + public function test_purge() + { + /* add a cache entry which does not match our key */ + $foreign_key = 'test_' . $this->driver->key_prefix . 'test'; + $this->assertSame(true, apcu_store($foreign_key, 0, 600)); + $this->assertSame(true, apcu_exists($foreign_key)); + + parent::test_purge(); + + $this->assertSame(true, apcu_exists($foreign_key)); + } } |