phpfastcache icon indicating copy to clipboard operation
phpfastcache copied to clipboard

Refactor Redis driver to read all keys efficiently

Open mapcentia opened this issue 1 year ago • 5 comments

The Redis driver's function to read all keys has been streamlined. The change is adding a loop to scan and merge the keys iteratively. This ensures that the function will work correctly, even when the number of keys scanned exceeds the MAX_ALL_KEYS_COUNT.

Proposed changes

This is a fix for https://github.com/PHPSocialNetwork/phpfastcache/issues/912

Types of changes

What types of changes does your code introduce to Phpfastcache?

  • [x] Bugfix (non-breaking change which fixes an issue)
  • [x] Improvement (non-breaking change which improves an existing code/behavior)
  • [ ] Deprecated third party dependency update
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Documentation/Typo/Resource update that does not involve any code modification

Agreement

I have read the CONTRIBUTING and CODING GUIDELINE docs

mapcentia avatar Jun 07 '24 10:06 mapcentia

The Redis driver's function to read all keys has been streamlined.

Where did you see that ? From which version ? Backward compatibility must be ensured if this is a very recent change of Redis extension.

Geolim4 avatar Jun 08 '24 23:06 Geolim4

I'm sorry for the not so good PR comment. By Redis driver's function to read all keys I mean the method driverReadAllKeys of lib/Phpfastcache/Drivers/Redis/Driver.php

mapcentia avatar Jun 10 '24 12:06 mapcentia

I just read this in the docs:

It is important to note that the MATCH filter is applied after elements are retrieved from the collection, just before returning data to the client. This means that if the pattern matches very little elements inside the collection, SCAN will likely return no elements in most iterations. An example is shown below:

I now understand the purpose of this PR. I'll check it asap.

Geolim4 avatar Jun 10 '24 12:06 Geolim4

It should be fixed. I've also made the same changed in the rediscluster driver

mapcentia avatar Sep 17 '24 19:09 mapcentia

Hello, thanks but the quality tools does not pass, please run them locally before pushing:

https://github.com/PHPSocialNetwork/phpfastcache/blob/master/CONTRIBUTING.md#developer-notes

Geolim4 avatar Sep 17 '24 19:09 Geolim4

Can you fix the CI @mapcentia ? Just fix Github actions, don't pay attention to Travis which will be removed soon !

Geolim4 avatar Nov 27 '24 19:11 Geolim4

thank you !

Geolim4 avatar Mar 02 '25 13:03 Geolim4