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: increment/decrement not working in Cache RedisHandler; method "remember" not listed in CacheInterface #6385

Closed
tzalexander opened this issue Aug 17, 2022 · 2 comments · Fixed by #6473
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@tzalexander
Copy link

tzalexander commented Aug 17, 2022

PHP Version

8.0

CodeIgniter4 Version

4.2.4

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

Database

MySQL

What happened?

The methods increment and decrement use the wrong php redis hashKey. Currently "data" is used - it should be "__ci_value" if I am right.

The method "remember" is not listed CacheInterface (system/Cache/) and is not suggested. See docs https://www.codeigniter.com/user_guide/libraries/caching.html.

Thank you

Steps to Reproduce

cache()->save('test', 5);  // test = 5
cache()->decrement('test', 2);

cache()->get('test'); // test = 5; it should be 3

Expected Output

3 instead of 5

Anything else?

No response

@tzalexander tzalexander added the bug Verified issues on the current code behavior or pull requests that will fix them label Aug 17, 2022
@paulbalandan
Copy link
Member

The methods increment and decrement use the wrong php redis hashKey. Currently "data" is used - it should be "__ci_value" if I am right.

Please open a PR with your changes so that we can discuss further. Also don't forget to add unit tests.

The method "remember" is not listed CacheInterface (system/Cache/) and is not suggested. See docs https://www.codeigniter.com/user_guide/libraries/caching.html.

This is intended. The "remember" method came after CacheInterface was finalized, so adding it would break custom implementations of the interface. It can be added to the interface though in a major version bump.

@paulbalandan
Copy link
Member

It seems the increment and decrement functions are untested.

// FIXME: I don't like all Hash logic very much. It's wasting memory.
// public function testIncrement()
// {
// }
// public function testDecrement()
// {
// }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants