{"id":13793045,"url":"https://github.com/rogeriopvl/php-lrucache","last_synced_at":"2026-03-05T18:39:10.033Z","repository":{"id":2796987,"uuid":"3797360","full_name":"rogeriopvl/php-lrucache","owner":"rogeriopvl","description":"LRU Cache implementation in PHP","archived":false,"fork":false,"pushed_at":"2014-12-07T21:32:22.000Z","size":173,"stargazers_count":67,"open_issues_count":1,"forks_count":29,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-07T13:06:42.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/rogeriopvl/phpLRUCache","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/rogeriopvl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-22T12:16:55.000Z","updated_at":"2024-11-23T21:17:39.000Z","dependencies_parsed_at":"2022-09-10T14:01:46.331Z","dependency_job_id":null,"html_url":"https://github.com/rogeriopvl/php-lrucache","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogeriopvl%2Fphp-lrucache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogeriopvl%2Fphp-lrucache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogeriopvl%2Fphp-lrucache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rogeriopvl%2Fphp-lrucache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rogeriopvl","download_url":"https://codeload.github.com/rogeriopvl/php-lrucache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883204,"owners_count":21819160,"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-08-03T22:01:21.013Z","updated_at":"2026-03-05T18:39:05.001Z","avatar_url":"https://github.com/rogeriopvl.png","language":"PHP","funding_links":[],"categories":["类库"],"sub_categories":["缓存"],"readme":"[![Build Status](https://travis-ci.org/rogeriopvl/php-lrucache.png)](https://travis-ci.org/rogeriopvl/php-lrucache)\n\n# PHP LRU Cache implementation\n\n## Intro\n\n### WTF is a LRU Cache?\n\nLRU stands for Least Recently Used. It's a type of cache that usually has a fixed capacity and discards the oldest entries. This is specially useful if you have the need to control the cache memory usage.\n\nIf you want more details about LRU Cache, you can read [this article][0] that explains it pretty well. Also if you want more interesting info, you can read [this great paper on LRU algorithms][1].\n\n### Implementation\n\nThis code is in it's early stages. I need to write more tests to find out the possible naive code parts in order to achieve some performance, if any is possible with PHP :P\n\nThis implementation is similar to a [LinkedHashMap][2]. Right now I'm just messing around with the code and decided to keep it simple, using a simple associative array as a naive hashmap. \n\n## Install (composer)\n\nAdd the package into your `composer.json` file:\n\n    \"require\": {\n        \"lrucache/lrucache\": \"master-dev\"\n    }\n\nThen run the command:\n\n    composer install\n\n## Usage\n\nUsage is pretty simple:\n\n    require_once('vendor/autoload.php'); // composer autoader\n    \n    $cache = new \\LRUCache\\LRUCache(1000);\n    \n    $cache-\u003eput('mykey', 'arrow to the knee');\n    \n    echo $cache-\u003eget('mykey');\n\nYou can use the tests to try things like load testing etc.\n\n\n[0]: http://java-planet.blogspot.pt/2005/08/how-to-set-up-simple-lru-cache-using.html\n[1]: http://www.vldb.org/conf/1994/P439.PDF\n[2]: http://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogeriopvl%2Fphp-lrucache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frogeriopvl%2Fphp-lrucache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frogeriopvl%2Fphp-lrucache/lists"}