Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Cache_Lite::Cache_Lite (hashed level 2)
3
--FILE--
4
<?php
5
 
6
require_once('callcache.inc');
7
require_once('tmpdir.inc');
8
require_once('cache_lite_base.inc');
9
 
10
$options = array(
11
    'cacheDir' => tmpDir() . '/',
12
    'lifeTime' => 60,
13
    'hashedDirectoryLevel' => 2
14
);
15
 
16
$Cache_Lite = new Cache_Lite($options);
17
multipleCallCache();
18
 
19
// Hack to clean cache directory structure
20
/**
21
 * rm() -- Vigorously erase files and directories.
22
 *
23
 * @param $fileglob mixed If string, must be a file name (foo.txt), glob pattern (*.txt), or directory name.
24
 *                        If array, must be an array of file names, glob patterns, or directories.
25
 */
26
function rm($fileglob)
27
{
28
   if (is_string($fileglob)) {
29
       if (is_file($fileglob)) {
30
           return unlink($fileglob);
31
       } else if (is_dir($fileglob)) {
32
           $ok = rm("$fileglob/*");
33
           if (! $ok) {
34
               return false;
35
           }
36
           return rmdir($fileglob);
37
       } else {
38
           $matching = glob($fileglob);
39
           if ($matching === false) {
40
               trigger_error(sprintf('No files match supplied glob %s', $fileglob), E_USER_WARNING);
41
               return false;
42
           }
43
           $rcs = array_map('rm', $matching);
44
           if (in_array(false, $rcs)) {
45
               return false;
46
           }
47
       }
48
   } else if (is_array($fileglob)) {
49
       $rcs = array_map('rm', $fileglob);
50
       if (in_array(false, $rcs)) {
51
           return false;
52
       }
53
   } else {
54
       trigger_error('Param #1 must be filename or glob pattern, or array of filenames or glob patterns', E_USER_ERROR);
55
       return false;
56
   }
57
 
58
   return true;
59
}
60
 
61
rm(tmpDir() . '/cache_*');
62
 
63
?>
64
--GET--
65
--POST--
66
--EXPECT--
67
==> First call (cache should be missed)
68
Cache Missed !
69
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
70
Done !
71
 
72
==> Second call (cache should be hit)
73
Cache Hit !
74
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
75
Done !
76
 
77
==> Third call (cache should be hit)
78
Cache Hit !
79
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
80
Done !
81
 
82
==> We remove cache
83
Done !
84
 
85
==> Fourth call (cache should be missed)
86
Cache Missed !
87
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
88
Done !
89
 
90
==> #5 Call with another id (cache should be missed)
91
Cache Missed !
92
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
93
Done !
94
 
95
==> We remove cache
96
Done !