I want to cache on demand some expensive calculations and store them in a plain file that I can fetch later on.
Is there any built-in function in WordPress Core Utilities that may handle adding, fetching, deleting cache?
Something that is similar to the following snippet:
if ($foo_string = $storage->fetch('foo')) {
$foo = unserialize($fooString);
} else {
// Do the work to calculate $foo.
$storage->save('foo', serialize($foo));
}