Is there any way to use a method to delete saved apc entries with regular expressions?
For example, some user queries that I want to remove from the cache when new data is entered into the database so that new data is displayed the next time the query is run.
Let's say you have a friend list request that is cached, but when a new friend is added, all cached friend requests for that user will be deleted ...
If I have these keys for the user friends list:
$sql = "SELECT * FROM friends WHERE userId = :userId";
$sqlKey = str_replace(":userId", $userId, $sql);
$key = $userId."-friend".md5('query'.$sqlKey);
$data = friendsArray;
apc_add($key, $data, 60 * 10);
Then the desired result would be to delete all entries that started with the current userId after starting to add a new friend request, to make sure that the friend list displays the new user the next time you look:
apc_delete("~$userId-friend([a-f0-9]+)~");
sql add friend sql , , , sql, , ?