Cache - Jet\Cache

As you know from the previous chapters, the cache is a very important element for MVC, for example, but of course not only there. It is advisable to cache everything that is read much more often than it is changed and that also takes some significant amount of time to compile the data. But you know that very well.

I'm writing about this mainly to explain that Jet\Cache* classes are not just for MVC even though they are used by it. And on the other hand, Jet\Cache* classes are not a universal and immediately usable system for creating a cache of anything.

In practice, we have come to the conclusion that a cache needs to be tailored to the purpose and the type of data it is supposed to work with. It's one thing to store a pre-generated e-shop category tree in a cache, for example, and it's another to store product information (since I've strayed into the e-shop area again), because one is a simple record and for the other I'll need some meta information at the same time. Of course, the cache needs to be fast and therefore as simple a system as possible. And complex systems that try to cover the whole universe and all its possibilities (which is not realistic anyway) are not the smallest and simplest thing you can find ...

That's why Jet\Cache* classes only represent low-level operations - i.e. backend caches. The kind of backend that aggregates repetitive operations, but doesn't handle the control logic. So, for example, it stores and reads data from/to files, but no longer solves how the files will be named. Or it handles communication with Redis, but no longer handles what the keys will be, and so on. That's the job of the superstructure above those classes that controls the logic of working with caches - for example, the aforementioned MVC caches.

Backend Overview

The following backends are currently available:

Jet\Cache_Files Basic backend using files to store data.
Jet\Cache_Redis Backend using Redis. It is important for really big projects and for running on multiple servers.

Methods Overview - Jet\Cache

Method Importance
public static resetOPCache(
) : void
It takes care of resetting PHP OP cache, which may be necessary with respect to file usage.
Previous chapter
Next chapter