{"action":"created","issue":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/11155","labels_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11155/labels{/name}","comments_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11155/comments","events_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11155/events","html_url":"https://github.com/phalcon/cphalcon/issues/11155","id":118974262,"number":11155,"title":"lifetime of modelsCache does not work","user":{"login":"fly512","id":16027300,"avatar_url":"https://avatars.githubusercontent.com/u/16027300?v=3","gravatar_id":"","url":"https://api.github.com/users/fly512","html_url":"https://github.com/fly512","followers_url":"https://api.github.com/users/fly512/followers","following_url":"https://api.github.com/users/fly512/following{/other_user}","gists_url":"https://api.github.com/users/fly512/gists{/gist_id}","starred_url":"https://api.github.com/users/fly512/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fly512/subscriptions","organizations_url":"https://api.github.com/users/fly512/orgs","repos_url":"https://api.github.com/users/fly512/repos","events_url":"https://api.github.com/users/fly512/events{/privacy}","received_events_url":"https://api.github.com/users/fly512/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/phalcon/cphalcon/labels/Need%20script%20to%20reproduce","name":"Need script to reproduce","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-26T05:26:30Z","updated_at":"2015-12-17T16:10:16Z","closed_at":null,"body":"my code \r\n```php\r\n$di->set('modelsCache', function () {\r\n\t$frontCache = new FrontendData(array(\r\n\t\t\"lifetime\" => 60\r\n\t));\r\n\t$cache = new BackendXcache(\r\n\t\t$frontCache,\r\n\t\tarray(\"prefix\" => \"model-cache\")\r\n\t);\r\n\treturn $cache;\r\n});\r\n```\r\ncphalcon code\r\n\r\nquery.zep\r\n```php\r\n/**\r\n * By defaut use use 3600 seconds (1 hour) as cache lifetime\r\n */\r\nif !fetch lifetime, cacheOptions[\"lifetime\"] {\r\n\tlet lifetime = 3600;\r\n}\r\n\r\n/**\r\n * \"modelsCache\" is the default name for the models cache service\r\n */\r\nif !fetch cacheService, cacheOptions[\"service\"] {\r\n\tlet cacheService = \"modelsCache\";\r\n}\r\n\r\nlet cache = this->_dependencyInjector->getShared(cacheService);\r\nif typeof cache != \"object\" {\r\n\tthrow new Exception(\"Cache service must be an object\");\r\n}\r\n\r\nlet result = cache->get(key, lifetime);\r\n```"},"comment":{"url":"https://api.github.com/repos/phalcon/cphalcon/issues/comments/165496412","html_url":"https://github.com/phalcon/cphalcon/issues/11155#issuecomment-165496412","issue_url":"https://api.github.com/repos/phalcon/cphalcon/issues/11155","id":165496412,"user":{"login":"oaass","id":2771625,"avatar_url":"https://avatars.githubusercontent.com/u/2771625?v=3","gravatar_id":"","url":"https://api.github.com/users/oaass","html_url":"https://github.com/oaass","followers_url":"https://api.github.com/users/oaass/followers","following_url":"https://api.github.com/users/oaass/following{/other_user}","gists_url":"https://api.github.com/users/oaass/gists{/gist_id}","starred_url":"https://api.github.com/users/oaass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oaass/subscriptions","organizations_url":"https://api.github.com/users/oaass/orgs","repos_url":"https://api.github.com/users/oaass/repos","events_url":"https://api.github.com/users/oaass/events{/privacy}","received_events_url":"https://api.github.com/users/oaass/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T16:10:16Z","updated_at":"2015-12-17T16:10:16Z","body":"I have this exact same issue\r\n\r\nservices.php\r\n\r\n```php\r\n$di->set('viewCache', function () use ($config) {\r\n\r\n    if ($config->application->development) {\r\n\r\n        $frontCache = new CacheFrontendNone;\r\n        return new CacheBackendMemory($frontCache);\r\n\r\n    } else {\r\n\r\n        $frontCache = new CacheFrontendOutput([\r\n            'lifetime' => 86400,\r\n        ]);\r\n\r\n        return new CacheBackendFile($frontCache, [\r\n            'cacheDir' => $config->cache->view->path,\r\n            'prefix' => $config->cache->view->prefix\r\n        ]);\r\n\r\n    }\r\n});\r\n```\r\n\r\naction\r\n\r\n```php\r\npublic function contactAction()\r\n{\r\n    $this->view->setVar('pageName', 'Contact');\r\n    \\Phalcon\\Tag::prependTitle('Contact');\r\n\r\n    $this->view->cache([\r\n        'key' => $this->cacheKey,\r\n        'lifetime' => 2592000\r\n    ]);\r\n\r\n    error_log(\"Cache lifetime: {$this->viewCache->getFrontend()->getLifetime()}\");\r\n\r\n    if ($this->viewCache->exists($this->cacheKey)) {\r\n        return;\r\n    }\r\n}\r\n```\r\n\r\nError log output: Cache lifetime: 86400\r\n\r\nPlease let me know if I misinterpret the way it's supposed to behave :)"}}