src/includes/classes/Core/Utils/DirCache.php
public function get(string $primary_key, $sub_key, int $max_age = 0, array $args = [])
    {
        if (!isset($primary_key, $sub_key)) {
            return null; // Not possible.
        }
        $file = $this->dir; // App-specific.
        $file .= '/'.$this->subPath($primary_key, $sub_key, $args);

        if (!is_file($file)) {
            return null; // Cache miss.
        } elseif ($max_age && time() - filemtime($file) > $max_age) {
            return null; // Cache miss, too old.
        } elseif (($cache = file_get_contents($file)) === false) {
            return null; // Cache miss, read failure.
        } elseif (($cache = unserialize($cache)) === false) {
            return null; // Cache miss, unserialize failure.
        }
        if (isset($cache['x___value'], $cache['x___expires'])) {
            if ($cache['x___expires'] && $cache['x___expires'] <= time()) {
                return null; // Cache miss, value has expired.
            } else {
                return $cache['x___value']; // Cache hit!
            }
        } else { // e.g., Perhaps stored by an older version.
            return null; // Cache miss, unexpected data.
        }
    }
public function get(string $primary_key, $sub_key, int $max_age = 0, array $args = [])
    {
        if (!isset($primary_key, $sub_key)) {
            return null; // Not possible.
        }
        $file = $this->dir; // App-specific.
        $file .= '/'.$this->subPath($primary_key, $sub_key, $args);

        if (!is_file($file)) {
            return null; // Cache miss.
        } elseif ($max_age && time() - filemtime($file) > $max_age) {
            return null; // Cache miss, too old.
        } elseif (($cache = file_get_contents($file)) === false) {
            return null; // Cache miss, read failure.
        } elseif (($cache = unserialize($cache)) === false) {
            return null; // Cache miss, unserialize failure.
        }
        if (isset($cache['x___value'], $cache['x___expires'])) {
            if ($cache['x___expires'] && $cache['x___expires'] <= time()) {
                return null; // Cache miss, value has expired.
            } else {
                return $cache['x___value']; // Cache hit!
            }
        } else { // e.g., Perhaps stored by an older version.
            return null; // Cache miss, unexpected data.
        }
    }
Get a cached value.

@since 170824.30708 Dir cache utils.

@param string     $primary_key Primary key.
@param string|int $sub_key     Sub-key to get.
@param int        $max_age     Max age (in seconds).
@param array      $args        Any behavioral args.

@return mixed|null Null if missing or expired.