Invalidating cache php
Here come two problems of storing data in the cache.First, there is a possibility that the storage is completely filled and you cannot save more data inside.Each invalidation request specifies a path pattern that identifies the object or set of objects that should be invalidated.The path pattern can be either a specific path, such as flag to the command. Invalidation is intended for use in exceptional circumstances, not as part of your normal workflow.For trouble-free functionality, it's recommended to use absolute paths. As soon as a part changes, the whole page is invalidated.So called tags are a very useful invalidation tool.Sometimes, you might want to remove an object from the cache prior to its normal expiration time.
After all, you wouldn't expect anything else, right?
We can assign a list of tags to each item stored in cache.
For example, suppose we have an HTML page with an article and comments, which we want to cache.
It's possible to define keys to which the cache will be binded (in this case, the If we only retrieve the data from our model in the template (on demand principle, or lazy), the cache will be particularly effective.
Caching the result of a function or method call can be achieved using the object using which we finally save the data to the cache.;-) Before we proceed to the first example, we need to think about place where to store data physically. For manipulation with cache, we use the Nette\Caching\Cache: It's possible to save any structure to the cache, not only strings. Web applications typically consist of a number of independent parts, and if they all cache data in the same storage (for example the same directory), sooner or later there would be collisions in names.