Skip to content

fix: Enhance Redis caching to support scalars cached as plain strings - #82

Merged
pocketarc merged 1 commit into
pocketarc:developfrom
madwings:fix/redis
Nov 2, 2026
Merged

pocketarc merged 1 commit into
pocketarc:developfrom
madwings:fix/redis

Conversation

@madwings

@madwings madwings commented Nov 2, 2026 •

Copy link
Copy Markdown

Preserving compatibility with 3.1-stable requires a bit more to ensure proper handling.

This pull request updates the Cache_redis driver to improve compatibility with cache data stored by CodeIgniter 3.1.x, especially for scalar values cached as plain strings. The changes ensure that data written by older versions can be read and incremented/decremented correctly in newer versions.

Backward compatibility and scalar handling improvements:

  • Updated the get() method to correctly detect and retrieve scalar values cached as plain strings by 3.1.x, using a new private _get_v31() helper. This ensures older cached data remains accessible.
  • Added the private _get_v31() method, which retrieves a scalar value and unserializes it if necessary, based on the presence in the _ci_redis_serialized set.

Increment/decrement logic improvements:

  • Modified the _increment() method to check the Redis type for the key and use incrBy for string types, ensuring correct behavior for values stored as plain strings in 3.1.x.

@pocketarc

Copy link
Copy Markdown
Owner

@madwings Thanks for this, great catch! _get_v31() does exactly what 3.1.x's get() did, which is great. The _increment() change breaks something that works today, though; I'll submit a follow-up PR to address it (plus a test to cover the behavior). Thanks for all your help with this!

@pocketarc
pocketarc merged commit 0fc1a12 into pocketarc:develop Nov 2, 2026
pocketarc added a commit that referenced this pull request Nov 2, 2026
.

* fix: Restore 3.1.x-compatible Redis counters and reads. Follow-up to #82.
* chore: Bump version to 3.4.7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants