Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions system/Cache/CacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public function save(string $key, $value, int $ttl = 60);
*/
public function delete(string $key);

/**
* Deletes items from the cache store matching a given pattern.
*
* @param string $pattern Cache items glob-style pattern
*
* @return int Number of deleted items
*/
public function deleteMatching(string $pattern): int;

/**
* Performs atomic incrementation of a raw stored value.
*
Expand Down
16 changes: 0 additions & 16 deletions system/Cache/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@

use Closure;
use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\Exceptions\BadMethodCallException;
use CodeIgniter\Exceptions\InvalidArgumentException;
use Config\Cache;
use Exception;

/**
* Base class for cache handling
Expand Down Expand Up @@ -98,18 +96,4 @@ public function remember(string $key, int $ttl, Closure $callback)

return $value;
}

/**
* Deletes items from the cache store matching a given pattern.
*
* @param string $pattern Cache items glob-style pattern
*
* @return int
*
* @throws Exception
*/
public function deleteMatching(string $pattern)
{
throw new BadMethodCallException('The deleteMatching method is not implemented.');
}
}
4 changes: 1 addition & 3 deletions system/Cache/Handlers/DummyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ public function delete(string $key)

/**
* {@inheritDoc}
*
* @return int
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): int
{
return 0;
}
Expand Down
4 changes: 1 addition & 3 deletions system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,8 @@ public function delete(string $key)

/**
* {@inheritDoc}
*
* @return int
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): int
{
$deleted = 0;

Expand Down
4 changes: 1 addition & 3 deletions system/Cache/Handlers/MemcachedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ public function delete(string $key)

/**
* {@inheritDoc}
*
* @return never
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): never
{
throw new BadMethodCallException('The deleteMatching method is not implemented for Memcached. You must select File, Redis or Predis handlers to use it.');
}
Expand Down
4 changes: 1 addition & 3 deletions system/Cache/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ public function delete(string $key)

/**
* {@inheritDoc}
*
* @return int
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): int
{
$matchedKeys = [];

Expand Down
4 changes: 1 addition & 3 deletions system/Cache/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ public function delete(string $key)

/**
* {@inheritDoc}
*
* @return int
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): int
{
/** @var list<string> $matchedKeys */
$matchedKeys = [];
Expand Down
4 changes: 1 addition & 3 deletions system/Cache/Handlers/WincacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ public function delete(string $key)

/**
* {@inheritDoc}
*
* @return never
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): never
{
throw new BadMethodCallException('The deleteMatching method is not implemented for Wincache. You must select File, Redis or Predis handlers to use it.');
}
Expand Down
4 changes: 1 addition & 3 deletions system/Test/Mock/MockCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ public function delete(string $key)

/**
* Deletes items from the cache store matching a given pattern.
*
* @return int
*/
public function deleteMatching(string $pattern)
public function deleteMatching(string $pattern): int
{
$count = 0;

Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ across all insert/update operations.
Interface Changes
=================

- **Cache:** The ``CacheInterface`` now includes the ``deleteMatching()`` method. If you've implemented your own caching driver from scratch, you will need to provide an implementation for this method to ensure compatibility.
- **Images:** The ``ImageHandlerInterface`` now includes a new method: ``clearMetadata()``. If you've implemented your own handler from scratch, you will need to provide an implementation for this method to ensure compatibility.

Method Signature Changes
Expand Down
Loading