phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\InvalidResultsetCacheService
Cache service must be an object implementing…
Error message
Cache service must be an object implementing Phalcon\Cache\CacheInterface or Psr\SimpleCache\CacheInterface
What it means
Type guard in Resultset::__construct when a cache entry is supplied: the passed cache value is neither Phalcon\Cache\CacheInterface nor Psr\SimpleCache\CacheInterface, so the resultset refuses an unusable cache service. The input at fault is the cache argument handed to the resultset.
Solutions
- Pass an object implementing CacheInterface (Phalcon or PSR-16) as the cache.
- Fix DI resolution so 'cache' returns the real cache service, not a wrong object.
- instanceof-check the cache before constructing the resultset when wiring it manually.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Resultset.zep:189 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/f167bd4e8c6f2272.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Resultset.zep:189
let this->rows = [];
return;
}
/**
* Valid resultsets are Phalcon\Db\ResultInterface instances
*/
let this->result = result;
/**
* Update the related cache if any
*/
if cache !== null {
if unlikely (
true !== is_a(cache, CacheInterface::class) &&
true !== is_a(cache, "Psr\\SimpleCache\\CacheInterface")
) {
throw new InvalidResultsetCacheService();
}
let this->cache = cache;
}
/**
* Do the fetch using only associative indexes
*/
result->setFetchMode(Enum::FETCH_ASSOC);
/**
* Consume the first row. The statement has already been executed by
* `Model\Query::executeSelect()`, so this costs no extra round trip,
* and it is the only way to tell an empty result-set from a populated
* one without asking the driver for a row count - which SQLite can
* only answer by running a second statement.
*/View on GitHub (pinned to b7419de9cd)