Giter Club home page Giter Club logo

Comments (13)

Geolim4 avatar Geolim4 commented on May 26, 2024

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:

  • Use the "Detach API" and reconfigure your cache item:
  • Disable useStaticItemCaching, see options in Wiki

So, It's not a bug, it's a feature :D

from phpfastcache.

marcos-guerrero avatar marcos-guerrero commented on May 26, 2024

Thank you very much for your attention and fast answer.
Ok, I'll study the options and decide what to do, but for me maybe the best option is to set ttl everytime I save an item, because relying on defaultTtl is not giving the behaviour I expected

from phpfastcache.

Geolim4 avatar Geolim4 commented on May 26, 2024

The default ttl only work for new cache items, that does not exist in the internal storage.
If an object with the specified key exists in the cache storage or in the backend, the default values are not applied.

from phpfastcache.

marcos-guerrero avatar marcos-guerrero commented on May 26, 2024

The default ttl only work for new cache items, that does not exist in the internal storage. If an object with the specified key exists in the cache storage or in the backend, the default values are not applied.

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

from phpfastcache.

Geolim4 avatar Geolim4 commented on May 26, 2024

The static storage is intended to avoid querying the original backend if the item has been already fetched using getItem* methods. If you disable useStaticItemCaching, the core will ignore static storage and will always query the original backend. Therefore if the item has expired and the backend returns nothing, you will get a new * not hit * fresh item with default TTL applied (900s)

from phpfastcache.

marcos-guerrero avatar marcos-guerrero commented on May 26, 2024

The static storage is intended to avoid querying the original backend if the item has been already fetched using getItem* methods. If you disable useStaticItemCaching, the core will ignore static storage and will always query the original backend. Therefore if the item has expired and the backend returns nothing, you will get a new * not hit * fresh item with default TTL applied (900s)

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?

from phpfastcache.

Geolim4 avatar Geolim4 commented on May 26, 2024

Disabling static storage may slightly reduce performances for applications that critically need fresh cache item.
In your case, I think you should, indeed, always specify the desired expiration time to be POLA-compliant :P

from phpfastcache.

marcos-guerrero avatar marcos-guerrero commented on May 26, 2024

POLA-compliant

Sorry, I don't catch it ...

from phpfastcache.

Geolim4 avatar Geolim4 commented on May 26, 2024

POLA-compliant

Sorry, I don't catch it ...

Principe Of Last Astonishment, look on Wikipedia.
Basically it means, always be as much explicit as you can, in order to avoid any undesired behavior from your code :)

from phpfastcache.

marcos-guerrero avatar marcos-guerrero commented on May 26, 2024

Ok! Interesting, thank you very much! I understand
Last but not least, I want to thank you for your software, phpfastcache rocks! It made our migration from apcu and memcached to redis very easy, and the tags feature is very very useful!

from phpfastcache.

Geolim4 avatar Geolim4 commented on May 26, 2024

Ok! Interesting, thank you very much! I understand Last but not least, I want to thank you for your software, phpfastcache rocks! It made our migration from apcu and memcached to redis very easy, and the tags feature is very very useful!

Thank you :)
Everything's good for you now ?

from phpfastcache.

marcos-guerrero avatar marcos-guerrero commented on May 26, 2024

Ok! Interesting, thank you very much! I understand Last but not least, I want to thank you for your software, phpfastcache rocks! It made our migration from apcu and memcached to redis very easy, and the tags feature is very very useful!

Thank you :) Everything's good for you now ?

Aye! Everything is ok for me now!

from phpfastcache.

Geolim4 avatar Geolim4 commented on May 26, 2024

Great :D

from phpfastcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.