-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Memcached.priority.phpt
50 lines (34 loc) · 1.18 KB
/
Memcached.priority.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Test: Nette\Caching\Storages\MemcachedStorage priority test.
*/
use Nette\Caching\Storages\MemcachedStorage;
use Nette\Caching\Storages\FileJournal;
use Nette\Caching\Cache;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
if (!MemcachedStorage::isAvailable()) {
Tester\Environment::skip('Requires PHP extension Memcache.');
}
Tester\Environment::lock('memcached-priority', TEMP_DIR);
$storage = new MemcachedStorage('localhost', 11211, '', new FileJournal(TEMP_DIR));
$cache = new Cache($storage);
// Writing cache...
$cache->save('nette-memcache-priority-key1', 'value1', array(
Cache::PRIORITY => 100,
));
$cache->save('nette-memcache-priority-key2', 'value2', array(
Cache::PRIORITY => 200,
));
$cache->save('nette-memcache-priority-key3', 'value3', array(
Cache::PRIORITY => 300,
));
$cache->save('nette-memcache-priority-key4', 'value4');
// Cleaning by priority...
$cache->clean(array(
Cache::PRIORITY => '200',
));
Assert::null($cache->load('nette-memcache-priority-key1'));
Assert::null($cache->load('nette-memcache-priority-key2'));
Assert::truthy($cache->load('nette-memcache-priority-key3'));
Assert::truthy($cache->load('nette-memcache-priority-key4'));