{"id":18929448,"url":"https://github.com/thecodingmachine/utils.cache.cache-interface","last_synced_at":"2026-03-16T14:30:17.530Z","repository":{"id":57020149,"uuid":"5739621","full_name":"thecodingmachine/utils.cache.cache-interface","owner":"thecodingmachine","description":"This Mouf PHP package only contains the interface that must be implemented by caching classes. Unless you want to implement your own caching method, you should import a cache package that will use this interface. For instance, common.utils.session-cache, or common.utils.file-cache.","archived":false,"fork":false,"pushed_at":"2018-06-20T09:49:03.000Z","size":20,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":9,"default_branch":"2.1","last_synced_at":"2025-02-16T12:30:30.625Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-09T17:12:15.000Z","updated_at":"2015-09-08T16:07:36.000Z","dependencies_parsed_at":"2022-08-22T20:31:14.823Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/utils.cache.cache-interface","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.cache.cache-interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.cache.cache-interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.cache.cache-interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Futils.cache.cache-interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/utils.cache.cache-interface/tar.gz/refs/heads/2.1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927823,"owners_count":19719835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:32:49.879Z","updated_at":"2026-03-16T14:30:17.477Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mouf Cache system\n=================\n\nThe Mouf framework is only an IOC framework. As such, it does not provide any means for managing any kind of cache. Hopefully, the Mouf team provides also a range of packages to manage the caching of objects.\n\nThe cache architecture\n----------------------\n\nMouf provides several implementations of caching, and you can provide your own if you want.\nEach cache mechanism must just extend the \u003ccode\u003eCacheInterface\u003c/code\u003e interface that is part of the\npackage utils/cache/cacheinterface.\n\nBy default, Mouf provides these caches:\n\n - \u003cb\u003eFileCache\u003c/b\u003e: a cache that writes cached elements in files, in a temporary folder.\u003c/li\u003e\n - \u003cb\u003eSessionCache\u003c/b\u003e: a cache that writes cached elements in the session of the current user. Therefore, this cache is local to a user.\u003c/li\u003e\n - \u003cb\u003eApcCache\u003c/b\u003e: a cache that uses the APC extension to store data.\u003c/li\u003e\n - \u003cb\u003eNoCache\u003c/b\u003e: a cache that... does not provide any cache. Can be useful for development purpose.\u003c/li\u003e\n\n\nThe cache methods\n-----------------\n\nEach class implementing the CacheInterface provides simple methods to get and set data in the cache:\n```php\ninterface CacheInterface {\n\t/**\n\t * Returns the cached value for the key passed in parameter.\n\t *\n\t * @param string $key\n\t * @return mixed\n\t */\n\tfunction get($key);\n\t\n\t/**\n\t * Sets the value in the cache.\n\t *\n\t * @param string $key The key of the value to store\n\t * @param mixed $value The value to store\n\t * @param int $timeToLive The time to live of the cache, in seconds.\n\t */\n\tfunction set($key, $value, $timeToLive = null);\n\t\n\t/**\n\t * Removes the object whose key is $key from the cache.\n\t *\n\t * @param string $key The key of the object\n\t */\n\tfunction purge($key);\n\t\n\t/**\n\t * Removes all the objects from the cache.\n\t *\n\t */\n\tfunction purgeAll();\n}\n```\n\n\nFor instance, to store some value in the cache, you just need to write:\n\n```php\n$cache-\u003eset(\"mykey\", \"myvalue\", 15);\n```\n\nThis will store the value \"myvalue\" in the cache, with key \"mykey\". The value will be stored for 15 seconds.\nIf within 15 seconds, we perform a call to retrieve the cache, the value will be retrieved:\n\n```php\n// Will print \"myvalue\" if called within 15 seconds.\necho $cache-\u003eget(\"mykey\");\n```\n\nThe third parameter is optional. If not passed, the default value will be used. The default value is \"forever\", which means the\ncached value will never time out. The default value can be overidden in the Mouf cache instance properties.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Futils.cache.cache-interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Futils.cache.cache-interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Futils.cache.cache-interface/lists"}