phalcon/cphalcon · error · Phalcon\Mvc\Model\Query\Exceptions\InvalidCachedResultset
Cache did not return a valid resultset
Error message
Cache did not return a valid resultset
What it means
Query::execute() retrieved an entry from the cache backend for the given key but its type is not an acceptable cached result (e.g. corrupted, evicted-partial, or foreign data stored under the same key), so this error is thrown. The faulty input is the invalid value found in the cache under the query's key.
Solutions
- Flush the stale/corrupted cache entry and re-run the query
- Ensure all writers to the key store resultsets produced by this query
- Bump the cache key namespace after changing result formats
Example fix
try { $rows = $query->execute(); } catch (\Exception $e) { $cache->delete($key); $rows = $query->execute(); } Defensive patterns
Strategy: fallback
Prevention
- Namespace cache keys per application version
- Validate cache payloads when writing them, and delete entries on serialization failure
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:381 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/3284a416d09128cd.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:381
/**
* 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);
}
if !empty result {
if unlikely typeof result != "object" {
throw new InvalidCachedResultset();
}
result->setIsFresh(false);
/**
* Check if only the first row must be returned
*/
if uniqueRow {
let preparedResult = result->getFirst();
} else {
let preparedResult = result;
}
return preparedResult;
}
let this->cache = cache;
}View on GitHub (pinned to b7419de9cd)