-
-
Notifications
You must be signed in to change notification settings - Fork 451
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving an item that is already in the pool after its expiration time fails #897
Comments
Hello, That's an expected behavior to be honest, not a bug. The item object is statically still present in the Phpfastcache internal storage. So you're basically just trying to write an expired item to Redis which return false, as expected. You have two options:
So, It's not a bug, it's a feature :D |
Thank you very much for your attention and fast answer. |
The default ttl only work for new cache items, that does not exist in the internal storage. |
Thank you again for your help, yes, I understand, that's why I'm thinking of not using defaulTtl anymore and substitute it with an explicit expiresAfter() that works in new and already existing items |
The static storage is intended to avoid querying the original backend if the item has been already fetched using getItem* methods. If you disable |
I understand that disabling static storage is easy and no code changes are required, but sure the performance will be affected, so having the chance to tweak my set($key, $value, $ttl) method and call expiresAfter() always (with default or explicit ttl) maybe is the solution with minimum code changes and not sacrifice performance... Don't you think so? |
Disabling static storage may slightly reduce performances for applications that critically need fresh cache item. |
Sorry, I don't catch it ... |
Principe Of Last Astonishment, look on Wikipedia. |
Ok! Interesting, thank you very much! I understand |
Thank you :) |
Aye! Everything is ok for me now! |
Great :D |
What type of issue is this?
Incorrect/unexpected/unexplainable behavior
Operating system + version
ubuntu 22.04
PHP version
8.2.3
Connector/Database version (if applicable)
redis_version:7.0.8
Phpfastcache version
9.1.2 馃敹
Describe the issue you're facing
I'm using Redis Driver with defaultTtl configured, so usually I don't use expiresAfter() nor expiresAt() Item API methods
Once the item is in the cache pool (because I just saved it with save() ItemPool method or because I retrieved it with getItem() method) , I sleep for defaultTtl + 1 seconds , just to be sure that the item is expired. Then, I save it again.
Expected behavior
The expected behaviour is the item to be saved no matter if explicit ttl is set or not
Code sample (optional)
Suggestion to fix the issue (optional)
No response
References (optional)
No response
Do you have anything more you want to share? (optional)
No response
Have you searched in our Wiki before posting ?
The text was updated successfully, but these errors were encountered: