phalcon/cphalcon · error · Phalcon\Mvc\Model\Query\Exceptions\MissingCacheKey

A cache key must be provided to identify the cached resultse

Error message

A cache key must be provided to identify the cached resultset in the cache backend

What it means

Error "A cache key must be provided to identify the cached resultset in the cache backend" thrown in phalcon/cphalcon.

Source

Thrown at phalcon/Mvc/Model/Query.zep:350

    public function execute(array bindParams = [], array bindTypes = [])
    {
        var adapter, cache, cacheLifetime, cacheOptions, cacheService,
            defaultBindParams, defaultBindTypes, intermediate, key, lifetime,
            mergedParams, mergedTypes, preparedResult, result, type, uniqueRow;

        let uniqueRow    = this->uniqueRow,
            cacheOptions = this->cacheOptions;

        if cacheOptions !== null {
            if unlikely typeof cacheOptions != "array" {
                throw new InvalidCachingOptions();
            }

            /**
             * The user must set a cache key
             */
            if unlikely !fetch key, cacheOptions["key"] {
                throw new MissingCacheKey();
            }

            if !fetch cacheService, cacheOptions["service"] {
                let cacheService = "modelsCache";
            }

            let cache = this->container->getShared(cacheService);

            if unlikely (true !== is_a(cache,  CacheInterface::class)) {
                throw new InvalidQueryCacheService();
            }

            /**
             * If the lifetime is different than the cache lifetime, assign
             * the cache lifetime to the current cache setting
             */
            let adapter       = cache->getAdapter();
            let cacheLifetime = adapter->getLifetime();

View on GitHub (pinned to b7419de9cd)

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Query.zep:350 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/38aadfe6e24f7ce7. Report an issue: GitHub.