Skip to content

[BUG]: Cache getKeys() return with prefix #17089

@Jeckerson

Description

@Jeckerson

Describe the bug
When calling getKeys() it returns full key names with prefix that is set during service provider declaration. It is not possible to directly remove keys with method delete(). It need to be cleaned of prefix and after that successfully removed.

To Reproduce

Steps to reproduce the behavior:

$keys = $this->cache->getAdapter()->getKeys();
Array (8) (
  [0] => "ph-memc-cachekey-random"
  [1] => "ph-memc-cachekey-random1"
)

Provide minimal script to reproduce the issue

This won't work due of ph-memc- prefix:

foreach ($this->cache->getAdapter()->getKeys() as $key) {
    $this->cache->getAdapter->delete($key);
}

But this will do:

foreach ($this->cache->getAdapter()->getKeys() as $key) {
    $this->cache->getAdapter->delete(str_replace('ph-memc-', '', $key));
}

Expected behavior
Do not show internal prefix and have possibility to delete key by just passing it from getKeys() array.

foreach ($this->cache->getAdapter()->getKeys() as $key) {
    $this->cache->getAdapter->delete($key);
}

Details

  • Phalcon version: 4.0.5
  • PHP Version: 7.4

Metadata

Metadata

Assignees

Labels

5.0The issues we want to solve in the 5.0 releasebugA bug reportstatus: mediumMedium

Type

No fields configured for Bug.

Projects

Status
Implemented

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions