Skip to content

Commit 760f659

Browse files
committed
Added onCacheDeleteItem event
1 parent 93147e2 commit 760f659

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/EVENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* onCacheGetItem
44
* Allow you to manipulate an item just before it gets returned by the getItem() method.
5+
onCacheDeleteItem
6+
* Allow you to manipulate an item just before it gets returned by the getItem() method.
57
* onCacheSaveItem
68
* Allow you to manipulate an item just before it gets saved by the driver.
79
* onCacheSaveDeferredItem

src/phpFastCache/Core/Pool/CacheItemPoolTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ public function deleteItem($key)
188188
if ($this->hasItem($key) && $this->driverDelete($item)) {
189189
$item->setHit(false);
190190
CacheManager::$WriteHits++;
191+
192+
/**
193+
* @eventName CacheCommitItem
194+
* @param $this ExtendedCacheItemPoolInterface
195+
* @param $item ExtendedCacheItemInterface
196+
*/
197+
$this->eventManager->dispatch('CacheDeleteItem', $this, $item);
198+
191199
/**
192200
* De-register the item instance
193201
* then collect gc cycles

src/phpFastCache/EventManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
* == ItemPool Events ==
2222
* @method Void onCacheGetItem() onCacheGetItem(Callable $callable)
23+
* @method Void onCacheDeleteItem() onCacheDeleteItem(Callable $callable)
2324
* @method Void onCacheSaveItem() onCacheSaveItem(Callable $callable)
2425
* @method Void onCacheSaveDeferredItem() onCacheSaveDeferredItem(Callable $callable)
2526
* @method Void onCacheCommitItem() onCacheCommitItem(Callable $callable)

0 commit comments

Comments
 (0)