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

Cache service must be an object implementing Phalcon\Cache\C

Error message

Cache service must be an object implementing Phalcon\Cache\CacheInterface

What it means

Error "Cache service must be an object implementing Phalcon\Cache\CacheInterface" thrown in phalcon/cphalcon.

Source

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

            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();

            if !fetch lifetime, cacheOptions["lifetime"] {
                let lifetime = cacheLifetime;
            }

            let result = false;
            if (cache->has(key)) {
                let result = cache->get(key);
            }

View on GitHub (pinned to b7419de9cd)

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Query.zep:360 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/8cd02596cc6538f3. Report an issue: GitHub.