{"id":38886150,"url":"https://github.com/shaj13/libcache","last_synced_at":"2026-01-17T14:47:08.015Z","repository":{"id":37053536,"uuid":"303087480","full_name":"shaj13/libcache","owner":"shaj13","description":"A Lightweight in-memory key:value cache library for Go.","archived":false,"fork":false,"pushed_at":"2023-03-09T00:09:52.000Z","size":28,"stargazers_count":174,"open_issues_count":2,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-06-18T15:22:26.500Z","etag":null,"topics":["arc-cache","cache","caching","fifo","go","golang","in-memory","lfu","library","lifo","lru","mru","ttl"],"latest_commit_sha":null,"homepage":"","language":"Go","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/shaj13.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,"publiccode":null,"codemeta":null}},"created_at":"2020-10-11T09:42:38.000Z","updated_at":"2024-03-22T13:01:27.000Z","dependencies_parsed_at":"2024-06-18T15:17:07.414Z","dependency_job_id":"e9118577-1e65-47b8-bb5a-2733dd4bae65","html_url":"https://github.com/shaj13/libcache","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/shaj13/libcache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaj13%2Flibcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaj13%2Flibcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaj13%2Flibcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaj13%2Flibcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaj13","download_url":"https://codeload.github.com/shaj13/libcache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaj13%2Flibcache/sbom","scorecard":{"id":815277,"data":{"date":"2025-08-11","repo":{"name":"github.com/shaj13/libcache","commit":"bb15979372e6e06c93b415c0d5c06fc1b02408a4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/19 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T14:09:08.676Z","repository_id":37053536,"created_at":"2025-08-23T14:09:08.676Z","updated_at":"2025-08-23T14:09:08.676Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28510905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["arc-cache","cache","caching","fifo","go","golang","in-memory","lfu","library","lifo","lru","mru","ttl"],"created_at":"2026-01-17T14:47:07.382Z","updated_at":"2026-01-17T14:47:08.008Z","avatar_url":"https://github.com/shaj13.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PkgGoDev](https://pkg.go.dev/badge/github.com/shaj13/libcache@v1.0.0)](https://pkg.go.dev/github.com/shaj13/libcache@v1.0.0)\n[![Go Report Card](https://goreportcard.com/badge/github.com/shaj13/libcache)](https://goreportcard.com/report/github.com/shaj13/libcache)\n[![Coverage Status](https://coveralls.io/repos/github/shaj13/libcache/badge.svg?branch=master)](https://coveralls.io/github/shaj13/libcache?branch=master)\n[![CircleCI](https://circleci.com/gh/shaj13/libcache/tree/master.svg?style=svg)](https://circleci.com/gh/shaj13/libcache/tree/master)\n\n# Libcache\nA Lightweight in-memory key:value cache library for Go. \n\n## Introduction \nCaches are tremendously useful in a wide variety of use cases.\u003cbr\u003e\nyou should consider using caches when a value is expensive to compute or retrieve,\u003cbr\u003e\nand you will need its value on a certain input more than once.\u003cbr\u003e\nlibcache is here to help with that.\n\nLibcache are local to a single run of your application.\u003cbr\u003e\nThey do not store data in files, or on outside servers.\n\nLibcache previously an [go-guardian](https://github.com/shaj13/go-guardian) package and designed to be a companion with it.\u003cbr\u003e\nWhile both can operate completely independently.\u003cbr\u003e\n\n\n## Features\n- Rich [caching API](https://pkg.go.dev/github.com/shaj13/libcache@v1.0.0#Cache)\n- Maximum cache size enforcement\n- Default cache TTL (time-to-live) as well as custom TTLs per cache entry\n- Thread safe as well as non-thread safe\n- Event-Driven callbacks ([Notify](https://pkg.go.dev/github.com/shaj13/libcache@v1.0.0#Cache))\n- Dynamic cache creation\n- Multiple cache replacement policies:\n  - FIFO (First In, First Out)\n  - LIFO (Last In, First Out)\n  - LRU (Least Recently Used)\n  - MRU (Most Recently Used)\n  - LFU (Least Frequently Used)\n  - ARC (Adaptive Replacement Cache)\n\n## Quickstart \n### Installing \nUsing libcache is easy. First, use go get to install the latest version of the library.\n\n```sh\ngo get github.com/shaj13/libcache\n```\nNext, include libcache in your application:\n```go\nimport (\n    _ \"github.com/shaj13/libcache/\u003cdesired-replacement-policy\u003e\"\n    \"github.com/shaj13/libcache\"\n)\n```\n\n### Examples\n**Note:** All examples use the LRU cache replacement policy for simplicity, any other cache replacement policy can be applied to them.\n#### Basic \n```go\npackage main \nimport (\n    \"fmt\" \n\n    \"github.com/shaj13/libcache\"\n    _ \"github.com/shaj13/libcache/lru\"\n)\n\nfunc main() {\n    size := 10\n    cache := libcache.LRU.NewUnsafe(size)\n    for i:= 0 ; i \u003c 10 ; i++ {\n        cache.Store(i, i)\n    }\n    fmt.Println(cache.Load(0)) // nil, false  \n    fmt.Println(cache.Load(1)) // 1, true\n}\n```\n\n#### Thread Safe \n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/shaj13/libcache\"\n\t_ \"github.com/shaj13/libcache/lru\"\n)\n\nfunc main() {\n\tdone := make(chan struct{})\n\n\tf := func(c libcache.Cache) {\n\t\tfor !c.Contains(5) {\n\t\t}\n\t\tfmt.Println(c.Load(5)) // 5, true\n\t\tdone \u003c- struct{}{}\n\t}\n\n\tsize := 10\n\tcache := libcache.LRU.New(size)\n\tgo f(cache)\n\n\tfor i := 0; i \u003c 10; i++ {\n\t\tcache.Store(i, i)\n\t}\n\n\t\u003c-done\n}\n```\n#### Unlimited Size\nzero capacity means cache has no limit and replacement policy turned off.\n```go\npackage main \nimport (\n    \"fmt\" \n\n    \"github.com/shaj13/libcache\"\n    _ \"github.com/shaj13/libcache/lru\"\n)\n\nfunc main() {\n\tcache := libcache.LRU.New(0)\n    for i:= 0 ; i \u003c 100000 ; i++ {\n        cache.Store(i, i)\n    }\n\tfmt.Println(cache.Load(55555))\n}\n```\n#### TTL\n```go\npackage main \nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/shaj13/libcache\"\n\t_ \"github.com/shaj13/libcache/lru\"\n)\n\nfunc main() {\n\tcache := libcache.LRU.New(10)\n\tcache.SetTTL(time.Second) // default TTL \n\t\n\tfor i:= 0 ; i \u003c 10 ; i++ {\n        cache.Store(i, i)\n\t}\n\tfmt.Println(cache.Expiry(1))\n\n\tcache.StoreWithTTL(\"mykey\", \"value\", time.Hour) // TTL per cache entry \n\tfmt.Println(cache.Expiry(\"mykey\"))\n\n}\n```\n\n#### Events \n```go\npackage main \nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/shaj13/libcache\"\n\t_ \"github.com/shaj13/libcache/lru\"\n)\n\nfunc main() {\n\tcache := libcache.LRU.New(10)\n\n\teventc := make(chan libcache.Event, 10)\n\tcache.Notify(eventc)\n\tdefer cache.Ignore(eventc)\n\n\tgo func() {\n\t\tfor {\n\t\t\te := \u003c-eventc\n\t\t\tfmt.Printf(\"Operation %s on Key %v \\n\", e.Op, e.Key)\n\t\t}\n\t}()\n\n\tcache.Load(1)\n\tcache.Store(1, 1)\n\tcache.Peek(1)\n\tcache.Delete(1)\n}\n```\n#### GC \n```go\npackage main \nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/shaj13/libcache\"\n\t_ \"github.com/shaj13/libcache/lru\"\n)\n\nfunc main() {\n\tcache := libcache.LRU.New(10)\n\n\teventc := make(chan libcache.Event, 10)\n\tcache.Notify(eventc)\n\tdefer cache.Ignore(eventc)\n\n\tgo func() {\n\t\tfor {\n\t\t\te := \u003c-eventc\n\t\t\tfmt.Printf(\"Operation %s on Key %v \\n\", e.Op, e.Key)\n\t\t}\n\t}()\n\n\tctx, cacnel := context.WithTimeout(context.Background(), time.Second*2)\n\tdefer cacnel()\n\n\tcache.StoreWithTTL(1, 1, time.Second)\n\n\t// GC is a long running function, evict expired items from the cache on time.\n\tlibcache.GC(ctx, cache)\n\n\tcache.StoreWithTTL(1, 1, time.Second)\n\ttime.Sleep(time.Second)\n\n\t// Runs a garbage collection and blocks the caller until the garbage collection is complete\n\tcache.GC()\n}\n```\n\n\n# Contributing\n1. Fork it\n2. Download your fork to your PC (`git clone https://github.com/your_username/libcache \u0026\u0026 cd libcache`)\n3. Create your feature branch (`git checkout -b my-new-feature`)\n4. Make changes and add them (`git add .`)\n5. Commit your changes (`git commit -m 'Add some feature'`)\n6. Push to the branch (`git push origin my-new-feature`)\n7. Create new pull request\n\n# License\nLibcache is released under the MIT license. See [LICENSE](https://github.com/shaj13/libcache/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaj13%2Flibcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaj13%2Flibcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaj13%2Flibcache/lists"}