RedBeanPHP\QueryWriter\AQueryWriter::putResultInCache PHP Method

putResultInCache() private method

A cache tag is used to make sure the cache remains consistent. In most cases the cache tag will be the bean type, this makes sure queries associated with a certain reference type will never contain conflicting data. Why not use the cache tag as a key? Well we need to make sure the cache contents fits the key (and key is based on the cache values). Otherwise it would be possible to store two different result sets under the same key (the cache tag). In previous versions you could only store one key-entry, I have changed this to improve caching efficiency (issue #400).
private putResultInCache ( string $cacheTag, string $key, array $values ) : void
$cacheTag string cache tag (secondary key)
$key string key to store values under
$values array content to be stored
return void
    private function putResultInCache($cacheTag, $key, $values)
    {
        if (isset($this->cache[$cacheTag])) {
            if (count($this->cache[$cacheTag]) > $this->maxCacheSizePerType) {
                array_shift($this->cache[$cacheTag]);
            }
        } else {
            $this->cache[$cacheTag] = array();
        }
        $this->cache[$cacheTag][$key] = $values;
    }