Cache File Backend queryKeys and directories

Hello. I have the following code as my cache

    $frontCache = new \Phalcon\Cache\Frontend\Data(array(
        "lifetime" => 86400
    $cache = new \Phalcon\Cache\Backend\File($frontCache, array(
        "cacheDir" => ROOT_PATH . '/var/cache/'

    $cacheKey = 'json/my_json.' . $key;
    $json = $cache->get($cacheKey);
    if (is_null($json)) {
        $json = make_json($key);

        $cache->save($cacheKey, $json);

It works perfectly and creates files inside the json dir /home/user/www/var/cache/json/json_1 for example but when i try the following code, it always return an empty array


So, as far as it seems, the $cache->get() and $cache->save() functions can work with subdirectories but the $cache->queryKeys() function cannot. So, is this a bug or i am using the cache service incorrectly?


It checks if any file in the cacheDir starts by the given pattern:

edited Oct '14

Right. And as far as it looks, the only way to access a certain subdirectory is to create a new \Phalcon\Cache\Backend\File object, right?

If so, should I go to GitHub to propose the inclusion of the setOptions() function to \Phalcon\Cache\Backend?


What kind of options you have in mind?


To change the cacheDir on the run, so i can have an abstract $cache on my DI and use it to DELETE files from var/cache/foo and from var/cache/bar