src/PeskyCMF/Db/Traits/TaggedCacheForDbSelects.php
protected function _getCachedData($affectsSingleRecord, array $cacheSettings, \Closure $callback) {
        /** @var CmfDbTable|TaggedCacheForDbSelects $this */
        $data = empty($cacheSettings['recache']) ? \Cache::get($cacheSettings['key'], '{!404!}') : '{!404!}';
        if ($data === '{!404!}') {
            $data = $callback();
            if ($data instanceof DbObject) {
                $data = $data->exists() ? $data->toPublicArray() : [];
            }
            $tags = $cacheSettings['tags'];
            $tags[] = $this->getModelCachePrefix();
            if ($affectsSingleRecord) {
                $tags[] = $this->getSelectOneCacheTag();
                if (!empty($data) && is_array($data) && !empty($data[$this->getPkColumnName()])) {
                    // create tag only for record with primary key value
                    $tags[] = $this->getRecordCacheTag($data);
                }
            } else {
                $tags[] = $this->getSelectManyCacheTag();
            }
            $cacher = \Cache::tags($tags);
            if (empty($cacheSettings['timeout'])) {
                $cacher->forever($cacheSettings['key'], $data);
            } else {
                $cacher->put($cacheSettings['key'], $data, $cacheSettings['timeout']);
            }
        }
        return $data;
    }
protected function _getCachedData($affectsSingleRecord, array $cacheSettings, \Closure $callback) {
        /** @var CmfDbTable|TaggedCacheForDbSelects $this */
        $data = empty($cacheSettings['recache']) ? \Cache::get($cacheSettings['key'], '{!404!}') : '{!404!}';
        if ($data === '{!404!}') {
            $data = $callback();
            if ($data instanceof DbObject) {
                $data = $data->exists() ? $data->toPublicArray() : [];
            }
            $tags = $cacheSettings['tags'];
            $tags[] = $this->getModelCachePrefix();
            if ($affectsSingleRecord) {
                $tags[] = $this->getSelectOneCacheTag();
                if (!empty($data) && is_array($data) && !empty($data[$this->getPkColumnName()])) {
                    // create tag only for record with primary key value
                    $tags[] = $this->getRecordCacheTag($data);
                }
            } else {
                $tags[] = $this->getSelectManyCacheTag();
            }
            $cacher = \Cache::tags($tags);
            if (empty($cacheSettings['timeout'])) {
                $cacher->forever($cacheSettings['key'], $data);
            } else {
                $cacher->put($cacheSettings['key'], $data, $cacheSettings['timeout']);
            }
        }
        return $data;
    }
Get data from cache or put data from $callback to cache
@param bool $affectsSingleRecord
@param array $cacheSettings - [
'key' => 'string, cache key',
'timeout' => 'int (minutes or unix timestamp), \DateTime, null (infinite)',
'tags' => ['custom', 'cache', 'tags'],
'recache' => 'bool, ignore cached data and replace it with fresh data'
]
@param \Closure $callback

@return array
@throws \PeskyORM\Exception\DbObjectException
@throws \PeskyORM\Exception\DbModelException
@throws \PeskyORM\Exception\DbConnectionConfigException
@throws \BadMethodCallException