Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Phalcon\Cache\Adapter\Stream file cache does not work correctly #16348

Closed
davidbayra opened this issue Jun 1, 2023 · 2 comments · Fixed by #16349
Closed

[BUG]: Phalcon\Cache\Adapter\Stream file cache does not work correctly #16348

davidbayra opened this issue Jun 1, 2023 · 2 comments · Fixed by #16349
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@davidbayra
Copy link

davidbayra commented Jun 1, 2023

The file cache does not work correctly if you use the prefix "en" and the key contains the word "men"

Steps to reproduce the behavior:

define('BASE_PATH', dirname(__DIR__));

use Phalcon\Cache\Adapter\Stream;
use Phalcon\Cache\Cache;
use Phalcon\Storage\SerializerFactory;

// case 1
$adapter = new Stream(new SerializerFactory(), [
    'storageDir' => BASE_PATH . '/cache',
    'prefix' => 'en', // it's not working correctly
]);

$cache = new Cache($adapter);

$cache->set('men', 123);
$cache->set('barmen', 'abc');
$cache->set('bar', 'xyz');

var_dump($cache->get('men')); // return null
var_dump($cache->get('barmen')); // return null
var_dump($cache->get('bar')); // return 'xyz'
var_dump($adapter->getKeys());

// case 2 
$adapter = new Stream(new SerializerFactory(), [
    'storageDir' => BASE_PATH . '/cache',
    'prefix' => 'eng',
]);

$cache = new Cache($adapter);

$cache->set('men', 123);
$cache->set('barmen', 'abc');
$cache->set('bar', 'xyz'); 

var_dump($cache->get('men')); // return 123
var_dump($cache->get('barmen')); // return 'abc'
var_dump($cache->get('bar')); // return 'xyz'
var_dump($adapter->getKeys());

Expected behavior
I expect to get the value 123 with the prefix "en" and the key "men"

$adapter = new Stream(new SerializerFactory(), [
    'storageDir' => BASE_PATH . '/cache',
    'prefix' => 'en',
]);

var_dump($cache->get('men')); // return 123
var_dump($cache->get('barmen')); // return 'abc'

Details

@davidbayra davidbayra added bug A bug report status: unverified Unverified labels Jun 1, 2023
@yesworld
Copy link

yesworld commented Jun 1, 2023

Phalcon version: 5.2.1
PHP Version: 8.2
Operating System: maxOs

# case 1
NULL
NULL 
string(3) "xyz"
array(3) { [0]=> string(5) "enbar" [1]=> string(8) "enbarmen" [2]=> string(5) "enmen" }

# case 2
int(123)
string(3) "abc"
string(3) "xyz"
array(3) { [0]=> string(6) "engbar" [1]=> string(9) "engbarmen" [2]=> string(6) "engmen" }

@niden niden self-assigned this Jun 1, 2023
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Jun 1, 2023
@niden niden mentioned this issue Jun 1, 2023
5 tasks
@niden niden linked a pull request Jun 1, 2023 that will close this issue
5 tasks
@niden niden added this to Phalcon v5 Jun 1, 2023
@niden niden moved this to In Progress in Phalcon v5 Jun 1, 2023
@niden
Copy link
Member

niden commented Jun 1, 2023

Resolved in #16349

Thank you @davidbayra and @yesworld for the report and examples.

@niden niden closed this as completed Jun 1, 2023
@niden niden moved this from In Progress to Implemented in Phalcon v5 Jun 1, 2023
@niden niden moved this from Implemented to Released in Phalcon v5 Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

3 participants