Skip to content

Commit e7f5f6a

Browse files
committed
Add remove method to cache interface
1 parent 9051fd5 commit e7f5f6a

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/wcmf/lib/io/Cache.php

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ public function get($section, $key);
5353
*/
5454
public function put($section, $key, $value, $lifetime=null);
5555

56+
/**
57+
* Remove the specified cache entry.
58+
* @param $section The cache section
59+
* @param $key The key
60+
*/
61+
public function remove($section, $key);
62+
5663
/**
5764
* Clear the given cache section. The wildcard char '*'
5865
* may be added to the section name in order to

src/wcmf/lib/io/impl/FileCache.php

+8
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ public function put($section, $key, $value, $lifetime=null) {
9090
$cache->save($item);
9191
}
9292

93+
/**
94+
* @see Cache::remove()
95+
*/
96+
public function remove($section, $key) {
97+
$cache = $this->getCache($section);
98+
$cache->deleteItem($this->sanitizeKey($key));
99+
}
100+
93101
/**
94102
* @see Cache::clear()
95103
*/

src/wcmf/lib/model/mapper/SelectStatement.php

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static function get(RDBMapper $mapper, $id=self::NO_CACHE) {
5555
else {
5656
$selectStmt = $cache->get($cacheSection, $cacheId);
5757
if (!$selectStmt) {
58+
$cache->remove($cacheSection, $cacheId);
5859
$selectStmt = new SelectStatement($mapper, $id);
5960
}
6061
$selectStmt->adapter = $mapper->getAdapter();

0 commit comments

Comments
 (0)