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

Camp 881 redis sets #10

Merged
merged 28 commits into from
Dec 3, 2020
Merged

Camp 881 redis sets #10

merged 28 commits into from
Dec 3, 2020

Conversation

jec3
Copy link
Contributor

@jec3 jec3 commented Dec 1, 2020

Adds CacheEnginesHelper::writeWithParent.

@jec3 jec3 requested review from dchancogne and rajivraman December 2, 2020 16:15
*
* @package Cake.Cache
*/
class Cache {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jec3 Could you just extend the Cache class so you only have to override the write() method instead of having to copy the entire class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jec3 Could you just extend the Cache class so you only have to override the write() method instead of having to copy the entire class?

@dchancogne I want all of the existing uses of the Cache class to use write override. If we extend Cache we'll have to update all existing uses of the Cache class to use our new class. This seems messier than overriding the class entirely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and the header comment is clear.

* @param string|array $parentKey Unused.
* @return bool True if the data was successfully cached, false on failure
*/
public function write($key, $data, $duration, $parentKey = '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jec3 So $parentKey is ignored here but you need to override the class and method to respect the new write() signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, because this implements the abstract class CacheEngine it must match the arguments specified there, which includes $parentKey.

Copy link
Member

@dchancogne dchancogne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jec3 Should work. Would be nice to find a cleaner way to do it that doesn't involve copying these core files. But it's all fairly limited in scope so worth a try to see if it helps performance.


public function key($key)
{
return Cache::engine($this->activeCache)->key($key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix for an existing bug. Without a key method defined here the definition in the abstract CacheEngine class is used, which modifies the key, unlike some other engines like the RedisTreeEngine, which uses the key exactly as provided.

@@ -0,0 +1,12 @@
FROM php:7.1-fpm-alpine
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cakephp 2.x requires mcrypt. PHP 7.1 is the last version that includes mcrypt so to avoid having to pull it from PECL I'm using 7.1 instead of 7.2.

$finalKeys[] = $key;
$childKeys = $this->_getChildKeys($key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid searching all child key sets, no attempt is made to find other parents who share the same children. This means that there can be child key sets that include keys that no longer exist. This will cause an unnecessary increase in memory usage overtime but it should be kept in check by the fact that deletion of a key also deletes its associated child key set.

@jec3
Copy link
Contributor Author

jec3 commented Dec 3, 2020

@dchancogne @rajivraman I did some reorganization based on a tip Elijah gave me. Can you give this one more pass?

@rajivraman
Copy link
Contributor

Adds CacheEnginesHelper::writeWithParent.

Looks good to me!

@jec3 jec3 merged commit 74534b3 into master Dec 3, 2020
@jec3 jec3 deleted the CAMP-881-redis-sets branch December 3, 2020 16:27
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.

3 participants