Skip to content

Commit 29d161c

Browse files
committed
docs: add deleteMatching method to caching page
1 parent dc61893 commit 29d161c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

user_guide_src/source/libraries/caching.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,27 @@ Class Reference
136136

137137
$cache->delete('cache_item_id');
138138

139+
.. php:method:: deleteMatching($pattern): bool
140+
141+
:param string $pattern: glob-style pattern to match cached items keys
142+
:returns: ``true`` on success, ``false`` if one of the deletes fails
143+
:rtype: bool
144+
145+
This method will delete multiple items from the cache store at once by
146+
matching their keys against a glob pattern.
147+
If one of the cache item deletion fails, the method will return FALSE.
148+
149+
.. important:: This method is only implemented for File, Redis and Predis handlers.
150+
Due to limitations, it couldn't be implemented for Memcached and Wincache handlers.
151+
152+
Example::
153+
154+
$cache->deleteMatching('prefix_*'); // deletes all keys starting with "prefix_"
155+
$cache->deleteMatching('*_suffix'); // deletes all keys ending with "_suffix"
156+
157+
For more information on glob-style syntax, please see
158+
`https://en.wikipedia.org/wiki/Glob_(programming) <https://en.wikipedia.org/wiki/Glob_(programming)#Syntax>`_.
159+
139160
.. php:method:: increment($key[, $offset = 1]): mixed
140161
141162
:param string $key: Cache ID

0 commit comments

Comments
 (0)