PHPSocialNetwork / phpfastcache

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
https://www.phpfastcache.com
MIT License
2.36k stars 452 forks source link

Refactor Redis driver to read all keys efficiently #913

Open mapcentia opened 2 months ago

mapcentia commented 2 months ago

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?

Agreement

I have read the CONTRIBUTING and CODING GUIDELINE docs

Geolim4 commented 2 months ago

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.

mapcentia commented 2 months ago

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

Geolim4 commented 2 months ago

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.