Skip to content

[NFR]: deleteMultiple() is documented for Cache, but not implemented in Redis adapter #16859

@kunalray1993

Description

@kunalray1993

Describe the bug

The cache documentation for Phalcon 5.9 shows that deleteMultiple() is available under cache operations:

  • delete
  • deleteMultiple
  • clear

However, when using Redis cache, calling deleteMultiple() results in the method not being found.

After checking the source code, I found that deleteMultiple() is not actually implemented in the Redis cache adapter, even though it is documented as supported.

Documentation reference

The current documentation states that deleteMultiple() can be used to delete multiple keys in one call:
Phalcon docs: Cache -> delete - deleteMultiple - clear

Expected behavior

Since the method is documented, deleteMultiple() should be implemented and callable when using the Redis cache adapter.

Also, Redis itself supports deleting multiple keys in a single command (DEL key1 key2 ...), so this can be implemented efficiently.

Actual behavior

Calling deleteMultiple() on Redis cache results in an error because the method is missing / not implemented.

Why this matters

Without deleteMultiple(), applications have to delete keys one by one, which leads to multiple Redis calls instead of a single bulk delete.

For example, with a custom implementation in my project that extends Phalcon\Cache\Adapter\Redis, Redis receives:

"DEL" "cache-key-1" "cache-key-2" "cache-key-3" "cache-key-4" "cache-key-5" "cache-key-6" "cache-key-7" "cache-key-8"

Sample code

for ($i = 1 ; $i <= 10 ; $i++) {
    $cacheKey = "cache-key-{$i}";
    CacheService::saveCacheData($cacheKey, $i, 60);
}

$cacheKeys = [];
for ($i = 1 ; $i <= 8 ; $i++) {
    $cacheKeys[] = "cache-key-{$i}";
}

CacheService::deleteMultipleCacheData($cacheKeys);

CacheService is our wrapper/service class for Redis cache operations.

Additional notes

I tested a custom implementation by extending Phalcon\Cache\Adapter\Redis and adding deleteMultiple() locally. It works as expected, and Redis executes a single multi-key DEL.

Since the underlying PHP Redis extension already supports multi-key deletion, it would be great if Phalcon either:

  1. Implements deleteMultiple() in the Redis adapter, or
  2. Updates the documentation to clarify that it is not currently supported.

Environment

  • Phalcon version: 5.9 docs referenced
  • Adapter: Redis

Suggested improvement

Implement deleteMultiple(array $keys): bool in the Redis adapter using Redis multi-key DEL (or UNLINK where appropriate).

Metadata

Metadata

Assignees

Labels

5.0The issues we want to solve in the 5.0 releasenew feature requestPlanned Feature or New Feature Request

Projects

Status

Implemented

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions