-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Redis caching/session enhancements #5519
Redis caching/session enhancements #5519
Conversation
if (! isset($data['__ci_type'], $data['__ci_value']) || $data['__ci_value'] === false) { | ||
return null; | ||
if(!(is_null($data = $this->redis->get($key)))) { | ||
$data = unserialize($data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storing php-serialized data is faster and more reliable than hard-coding the data types we anticipate.
@@ -204,19 +269,17 @@ public function close(): bool | |||
{ | |||
if (isset($this->redis)) { | |||
try { | |||
$pingReply = $this->redis->ping(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remove the ping()
call, because when a ping is unsuccessful/redis connection is broken, phpredis will throw an exception, just as it will with del()
below.
@@ -28,13 +27,17 @@ class PredisHandler extends BaseHandler | |||
* @var array | |||
*/ | |||
protected $config = [ | |||
'scheme' => 'tcp', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 'scheme' since this is not exposed via Cache.php and is not used throughout this file. I have a future to-do for myself to add TLS support, then maybe we can reintroduce scheme here as well as in Cache.php and RedisHandler.php, and set it up to accept either tls or tcp.
default: | ||
return null; | ||
} | ||
$data = $this->redis->get($key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change at line 187 makes all the old type determination/storage unnecessary.
I noticed one of the workflows spat out this 'arcitecture violation' error:
If this is a violation of the overall intended CI structure, feel free to remove ConfiguredCacheHandler, I can maybe set it up as a package that can be added on. We'll have to update the docs to remove this as well. Also: There is indeed a decent amount of duplicated code for parsing cache configs, initiating phpredis/predis connections, etc. Happy to create common functions to handle this and eliminate dups. However, I'm concerned that this could cause another 'arcitecture violation' like ConfiguredCacheHandler does. Definitely open to suggestions/direction for where to put those common functions. |
fix: Deserialization of Untrusted Data in old()
Co-authored-by: kenjis <[email protected]>
Prep for 4.1.6 release
4.1.6 Ready code
… of type float is deprecated Fixes codeigniter4#5535
Revert workaround for php-coveralls
Remove experimental flag for PHP 8.1
docs: add Security advisory in CHANGELOG.md
docs: minor addition to changelogs/v4.1.6.rst and upgrade_416.rst
Update modified Kint files in `ThirdParty`
…onnectDuration fix: BaseConnection::getConnectDuration() number_format(): Passing null to parameter
Fix: Deletion timestamp of the Model is updated when a record that has been soft-deleted is deleted again
refactor: CURLRequest and the slow tests
docs: Clarification when working with model pagination.
docs: fix routing.rst
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
…rstv docs: improve pagination.rst
…hpunit chore: generate coverage report by PHPUnit only on PHP 8.0
Signed-off-by: Andrey Pyzhikov <[email protected]>
Fix: Added alias escaping in subquery
fix: spark migrate:status does not show status with different namespaces
…ist-dot-notation Refactor `if_exist` validation with dot notation
…empty-arrays Fix `array_flatten_with_dots` ignores empty array values
Add cluster support for Redis and Predis cache and session handlers. Add new session handler to use whatever the configured caching mechanism is.
Changes after reviewing my PR
…ity improvements. Removed ConfiguredCacheHandler session handler, will add it separately. Predis cluster compatibility fixes.
@kenjis pulled in latest |
@mv-steven It seems you did something wrong with git. |
@kenjis I did follow those instructions. I'll setup a new, clean PR. But to be honest if this is going to continue to be such a painful process to get some relatively simple changes merged in, I'm gonna skip this and make this available as plugins. |
@mv-steven I'm sorry, it seems you are not familiar with git. I checked out your branch and followed the instruction.
All you have to do is to resolve the conflicts, and compete the |
@kenjis I did follow the instructions in the link you posted but I only saw 2 or 3 conflicts, which I resolved. But I do not claim to be a git expert :) Maybe there's some kind of local cache that was out of date. I'm going to squash my commits and open a new PR, hopefully that will clean everything up. |
Add cluster support for Redis and Predis cache and session handlers. Add new session handler to use whatever the configured caching mechanism is.
Each pull request should address a single issue and have a meaningful title.
Description
Checklist:
Testing
I tested against a redis server and redis cluster, using Redis/Predis as the cache/session handlers, then using the new ConfiguredCacheHandler session handler. Would like to setup unit tests but not sure how to handle that since there are infrastructure dependencies. Maybe in the future we can somehow include a docker command to spin up a redis image in unit tests.