Search code examples
phpphalcon

Phalcon: backCache does not work


I try to cache data, but script always do request to DB

public static function getByCitiesIDs(array $ids): array
{
    $di = Di::getDefault();

    /** @var Backend $cache */
    $cache = $di->get('backCache');

    $key = 'get_flights_by_cities:' . md5(json_encode($ids));

    $result = $cache->get($key);

    if ($result === null) {
        $result = RequestToDB();

        $cache->save($key, $result, 36000);
    }
    return $result;
}

What do I do wrong?


Solution

  • Phalcon is unable to write to directory. Check your system write permissions. Give Server (Apache or else) permission to write to directory.