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
Globally disable cache #212
Comments
The foundation for this feature is already here- there's a pool disable feature that exists and gets activated in the case of certain errors, and it's controlled by the "isDisabled" property- https://github.com/tedious/Stash/blob/master/src/Stash/Pool.php#L35 If you wanted to make a pull request to expose that via a "disable" function I would merge it. That being said, my advice for development is to use the "ephemeral" driver. It stores things only for the current request, and once that php process or request is finished the data goes away with it. This driver is the default driver if you don't pass one in. |
We would also have the use case for having an admin panel, where the customer (read: admin user of service) can enable or disable caching on API calls themselves (for whatever reason). I'll give a PR a quick go. |
Pull request made. |
A note I should make is that I couldn't use the isDisabled property for this, since that would only return null, which isn't what the desired effect was. The desired effect was to force the cache to miss, effectively meaning that the cache is no longer there (Eg. doing $item->set($response) ... $item->get() with a forced miss a round the set would be the same as return $response) |
any news on a merge? |
It would only return null where? I'm confused as to what was wrong with using isDisable. |
When using isDisable(), isMiss() would return null. This is unexpected, because the feature is that isMiss() would be forced, so that the cache is effectively bypassed. |
I was incorrect on this, it isn't isMiss() that returns null, it is get() that returns null. Explained in PR. isDisabled will force the cache to be bypassed, but the stored value cannot be fetched, so it is effectively useless for this use case. |
So you want a read only cache? |
A read only cache, but that still writes to the cache so that when the site comes out of dev, the cache doesn't have to be regenerated for the items that are correct |
A read-only cache is one that you can read items from but not put items into it (you can "read" the cache but not "write" the cache). What you want is the opposite- a write only cache that doesn't allow reading. Lets be clear about this in the API. I'm not going to approve this as "disable" because that's not what it does. There are three states here that each need to be defined-
A "setMode" function that takes these options seems like the way to go. |
If an appropriate name was found, would you accept this as a renamed method? Eg. writeOnly(), forceMiss() or something along those lines? Or do you mean that we would have some constants defined, and that as well as ->setDriver() we would also have a setMode() which would take the value of one of the four bullet points? |
I'd prefer the setMode method, although I think it should skip the Ephemeral option (that can work using the ephemeral driver as is). So the options would be-
|
OK I'll give be this a go tomorrow if you haven't started. Want me to
|
Starting fresh might make the most sense. |
I'll create a new issue for this then, so we can discuss it before I start work. |
I am looking for a way to globally disable cache for a pool, for use during development.
I was hoping something like $pool->disable() would exist, which would then simply force isMiss() to return true, so that the operation happens always.
This would mean that regardless of the timeout time, it would be ignored.
The text was updated successfully, but these errors were encountered: