Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ApcuCache.php
Go to the documentation of this file.
1<?php
2
4
7
18
22 public function __construct($root, $postfix = "") {
23 parent::__construct ( $root, $postfix );
24 }
25
32 public function exists($key) {
33 $success = false;
34 \apc_fetch ( $this->getRealKey ( $key ), $success );
35 return $success;
36 }
37
38 public function store($key, $code, $tag = null) {
39 \apc_store ( $this->getRealKey ( $key ), $code );
40 }
41
42 protected function getRealKey($key) {
43 return $key;
44 }
45
52 public function fetch($key) {
53 return \apc_fetch ( $this->getRealKey ( $key ) );
54 }
55
62 public function file_get_contents($key) {
63 return \apc_fetch ( $this->getRealKey ( $key ) );
64 }
65
72 public function getTimestamp($key) {
73 $key = $this->getRealKey ( $key );
74 $cache = \apc_cache_info ( 'user' );
75 if (empty ( $cache ['cache_list'] )) {
76 return false;
77 }
78 foreach ( $cache ['cache_list'] as $entry ) {
79 if ($entry ['info'] != $key) {
80 continue;
81 }
82 $creationTime = $entry ['creation_time'];
83 return $creationTime;
84 }
85 return \time ();
86 }
87
88 public function remove($key) {
89 \apc_delete ( $this->getRealKey ( $key ) );
90 }
91
92 public function clear() {
93 \apc_clear_cache ( 'user' );
94 }
95
96 protected function getCacheEntries($type) {
97 $entries = $this->getAllEntries ();
98 return \array_filter ( $entries, function ($v) use ($type) {
99 return UString::startswith ( $v ['info'], $type );
100 } );
101 }
102
103 protected function getAllEntries() {
104 $entries = [ ];
105 $cache = \apc_cache_info ( 'user' );
106 if (! empty ( $cache ['cache_list'] )) {
107 $entries = $cache ['cache_list'];
108 }
109 return $entries;
110 }
111
112 public function getCacheFiles($type) {
113 $result = [ ];
114 $entries = $this->getCacheEntries ( $type );
115 foreach ( $entries as $entry ) {
116 $key = $entry ['info'];
117 if (UString::startswith ( $key, $type )) {
118 $result [] = new CacheFile ( \ucfirst ( $type ), $key, $entry ['creation_time'], $entry ['mem_size'], $key );
119 }
120 }
121 if (\count ( $result ) === 0)
122 $result [] = new CacheFile ( \ucfirst ( $type ), "", "", "" );
123 return $result;
124 }
125
126 public function clearCache($type) {
127 $entries = $this->getCacheEntries ( $type );
128 foreach ( $entries as $entry ) {
129 $this->remove ( $entry ['info'] );
130 }
131 }
132
133 public function getEntryKey($key) {
134 return $this->getRealKey ( $key );
135 }
136}
This class is responsible for storing Arrays in PHP files.
APC cache implementation Ubiquity\cache\system$ApcCache This class is part of Ubiquity.
Definition ApcuCache.php:17
file_get_contents($key)
return data stored for the given key.
Definition ApcuCache.php:62
__construct($root, $postfix="")
Initializes the apc cache-provider.
Definition ApcuCache.php:22
fetch($key)
Fetches data stored for the given key.
Definition ApcuCache.php:52
clear()
Clears all cache entries.
Definition ApcuCache.php:92
store($key, $code, $tag=null)
Caches the given data with the given key.
Definition ApcuCache.php:38
exists($key)
Check if annotation-data for the key has been stored.
Definition ApcuCache.php:32
getTimestamp($key)
Returns the timestamp of the last cache update for the given key.
Definition ApcuCache.php:72
String utilities.
Definition UString.php:15