{"id":23413194,"url":"https://github.com/beste/in-memory-cache-php","last_synced_at":"2026-04-27T14:01:08.521Z","repository":{"id":211500358,"uuid":"729327941","full_name":"beste/in-memory-cache-php","owner":"beste","description":"A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.","archived":false,"fork":false,"pushed_at":"2025-09-29T22:05:35.000Z","size":59,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T23:28:20.602Z","etag":null,"topics":["cache","php","psr-6"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beste.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jeromegamez"}},"created_at":"2023-12-08T23:04:30.000Z","updated_at":"2025-09-29T22:05:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b3a2b75-e435-46d3-a007-c45c376d1304","html_url":"https://github.com/beste/in-memory-cache-php","commit_stats":null,"previous_names":["beste/in-memory-cache-php"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/beste/in-memory-cache-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beste%2Fin-memory-cache-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beste%2Fin-memory-cache-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beste%2Fin-memory-cache-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beste%2Fin-memory-cache-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beste","download_url":"https://codeload.github.com/beste/in-memory-cache-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beste%2Fin-memory-cache-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32339290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cache","php","psr-6"],"created_at":"2024-12-22T19:29:36.590Z","updated_at":"2026-04-27T14:01:08.468Z","avatar_url":"https://github.com/beste.png","language":"PHP","funding_links":["https://github.com/sponsors/jeromegamez"],"categories":[],"sub_categories":[],"readme":"# PSR-6 In-Memory Cache\n\nA [PSR-6](https://www.php-fig.org/psr/psr-6/) In-Memory cache that can be used as a default implementation and in tests.\n\n[![Current version](https://img.shields.io/packagist/v/beste/in-memory-cache.svg?logo=composer)](https://packagist.org/packages/beste/in-memory-cache)\n[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/beste/in-memory-cache)](https://packagist.org/packages/beste/in-memory-cache)\n[![Monthly Downloads](https://img.shields.io/packagist/dm/beste/in-memory-cache.svg)](https://packagist.org/packages/beste/in-memory-cache/stats)\n[![Total Downloads](https://img.shields.io/packagist/dt/beste/in-memory-cache.svg)](https://packagist.org/packages/beste/in-memory-cache/stats)\n[![Tests](https://github.com/beste/in-memory-cache-php/actions/workflows/tests.yml/badge.svg)](https://github.com/beste/in-memory-cache-php/actions/workflows/tests.yml)\n\n## Installation\n\n```shell\ncomposer require beste/in-memory-cache\n```\n\n## Usage\n\n```php\nuse Beste\\Cache\\InMemoryCache;\n\n$cache = new InMemoryCache();\n\n$item = $cache-\u003egetItem('key');\n\nassert($item-\u003eisHit() === false);\nassert($item-\u003eget() === null);\n\n$item-\u003eset('value');\n$cache-\u003esave($item);\n\n// Later...\n\n$item = $cache-\u003egetItem('key');\n\nassert($item-\u003eisHit() === true);\nassert($item-\u003eget() === 'value');\n```\n\nYou can also provide your own [PSR-20](https://www.php-fig.org/psr/psr-20/) clock implementation, for example a frozen\nclock for testing, for example from the [`beste/clock` library](https://github.com/beste/clock).\n\n```php\nuse Beste\\Clock\\FrozenClock;\nuse Beste\\Cache\\InMemoryCache;\n\n$clock = FrozenClock::fromUTC()\n$cache = new InMemoryCache();\n\n$item = $cache-\u003egetItem('key');\n$item-\u003eset('value')-\u003eexpiresAfter(new DateInterval('PT5M'));\n$cache-\u003esave($item);\n\n$clock-\u003esetTo($clock-\u003enow()-\u003eadd(new DateInterval('PT2M')));\nassert($cache-\u003egetItem('key')-\u003eisHit() === true);\n\n$clock-\u003esetTo($clock-\u003enow()-\u003eadd(new DateInterval('PT5M')));\nassert($cache-\u003egetItem('key')-\u003eisHit() === false);\n```\n\n## Running tests\n\n```shell\ncomposer test\n```\n\n## License\n\nThis project is published under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeste%2Fin-memory-cache-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeste%2Fin-memory-cache-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeste%2Fin-memory-cache-php/lists"}