{"id":24738628,"url":"https://github.com/zweifisch/sieve","last_synced_at":"2025-10-10T07:32:56.833Z","repository":{"id":222651004,"uuid":"757992757","full_name":"zweifisch/sieve","owner":"zweifisch","description":"a simple yet efficient cache","archived":false,"fork":false,"pushed_at":"2024-02-19T12:43:30.000Z","size":883,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T11:52:23.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/zweifisch.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-15T12:11:28.000Z","updated_at":"2024-02-24T00:48:40.000Z","dependencies_parsed_at":"2024-02-19T13:57:16.560Z","dependency_job_id":null,"html_url":"https://github.com/zweifisch/sieve","commit_stats":null,"previous_names":["zweifisch/sieve"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsieve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsieve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsieve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fsieve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweifisch","download_url":"https://codeload.github.com/zweifisch/sieve/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235936104,"owners_count":19068828,"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":"2025-01-27T22:55:06.011Z","updated_at":"2025-10-10T07:32:51.460Z","avatar_url":"https://github.com/zweifisch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sieve\n\na simple yet efficient cache, [original introduction](https://cachemon.github.io/SIEVE-website/blog/2023/12/17/sieve-is-simpler-than-lru/)\n\n![algo animation](https://cachemon.github.io/SIEVE-website/blog/assets/sieve/sieve_diagram_animation.gif)\n\n## Usage\n\nfor Node.js, install via npm: `npm install @zf/sieve`\n\n```typescript\nimport { SieveCache, LRUCache, LFUCache } from '@zf/sieve'\n\nconst cache = new SieveCache\u003cstring\u003e(3 /* capacity */)\ncache.set('key', 'value')\ncache.get('key')\n```\n\nfor Deno\n\n```typescript\nimport { SieveCache, LRUCache, LFUCache } from \"https://deno.land/x/sieve/mod.ts\"\n```\n\n## Benchmark\n\n[Benchmark](/benchmark.ts) reading 1 million normally distributed items through a cache with a capacity of 100 compared with the [LRU](https://deno.land/x/lru@1.0.2) package \nshowing SIEVE is more performant, while the cache hit/miss ratio is about the same:\n\n![chart](/chart.png)\n\nIt turned out that the LRU package's implementation is not very efficient, so I wrote my own [LRU](/lru.ts), and it is actually better than SIEVE:\n\n![chart](/lru.png)\n\nAnyway, the cache hit/miss ratio is of much greater importance, and it is determined by the data distribution.\n\nAdded [LFU](/lfu.ts), which has the best hit rate for normally distributed data:\n\n![chart](lfu.png)\n\n\n## Dev\n\n```sh\ndeno test\n```\n\n```sh\ndeno run --allow-all build_npm.ts 1.0.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fsieve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweifisch%2Fsieve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fsieve/lists"}