{"id":20843821,"url":"https://github.com/num30/go-cache","last_synced_at":"2025-10-09T22:12:16.016Z","repository":{"id":39674262,"uuid":"487764596","full_name":"num30/go-cache","owner":"num30","description":"An in-memory key:value store/cache (similar to Memcached) library that takes advantage of Go Generics ","archived":false,"fork":false,"pushed_at":"2023-09-05T07:28:59.000Z","size":214,"stargazers_count":16,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-09T01:48:40.081Z","etag":null,"topics":["cache","generic","go","golang"],"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/num30.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,"zenodo":null}},"created_at":"2022-05-02T08:07:31.000Z","updated_at":"2025-03-05T18:22:56.000Z","dependencies_parsed_at":"2025-05-09T01:48:41.548Z","dependency_job_id":"44f7e124-dfb9-41ff-a461-42c946b58ee6","html_url":"https://github.com/num30/go-cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/num30/go-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/num30%2Fgo-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/num30%2Fgo-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/num30%2Fgo-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/num30%2Fgo-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/num30","download_url":"https://codeload.github.com/num30/go-cache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/num30%2Fgo-cache/sbom","scorecard":{"id":698500,"data":{"date":"2025-08-11","repo":{"name":"github.com/num30/go-cache","commit":"af9deadd7c7670625b10bcdfb29e8e33c9b5d7ee"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yaml:1","Info: no jobLevel write permissions found"],"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"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":"Code-Review","score":0,"reason":"Found 0/27 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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/num30/go-cache/test.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/num30/go-cache/test.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yaml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/num30/go-cache/test.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/num30/go-cache/test.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/num30/go-cache/test.yaml/main?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/test.yaml:43","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"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":"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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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 4 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":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0322 / GHSA-cg3q-j54f-5p7p","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37","Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"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-22T04:27:42.545Z","repository_id":39674262,"created_at":"2025-08-22T04:27:42.545Z","updated_at":"2025-08-22T04:27:42.545Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002128,"owners_count":26083307,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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","generic","go","golang"],"created_at":"2024-11-18T02:07:26.358Z","updated_at":"2025-10-09T22:12:15.997Z","avatar_url":"https://github.com/num30.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-cache\n\n[![test-and-lint](https://github.com/num30/go-cache/actions/workflows/test.yaml/badge.svg)](https://github.com/num30/go-cache/actions/workflows/test.yaml)\n[![codecov](https://codecov.io/gh/num30/go-cache/branch/main/graph/badge.svg?token=FMvJ4TbC2r)](https://codecov.io/gh/num30/go-cache)\n[![Go Report Card](https://goreportcard.com/badge/github.com/num30/go-cache)](https://goreportcard.com/report/github.com/num30/go-cache)\n[![Go Reference](https://pkg.go.dev/badge/github.com/num30/go-cache.svg)](https://pkg.go.dev/github.com/num30/go-cache)\n\nℹ️ go-cache is a port of great [go-cache](https://github.com/patrickmn/go-cache) library that was written by @patrickmn. The main defference is that it relies on generics instead of reflection.\n\ngo-cache is a  in-memory key:value store/cache similar to memcached that is\nsuitable for applications running on a single machine. Its major advantage is\nthat, being essentially a thread-safe `map[string][T]` with expiration\ntimes, it doesn't need to serialize or transmit its contents over the network.\n\nAny object can be stored, for a given duration or forever, and the cache can be\nsafely used by multiple goroutines.\n\nAlthough go-cache isn't meant to be used as a persistent datastore, the entire\ncache can be saved to and loaded from a file (using `c.Items()` to retrieve the\nitems map to serialize, and `NewFrom()` to create a cache from a deserialized\none) to recover from downtime quickly. (See the docs for `NewFrom()` for caveats.)\n\n### Installation\n\n`go get github.com/num30/go-cache`\n\n### Usage\n\n```go\nimport (\n\t\"fmt\"\n\t\"github.com/num30/go-cache\"\n\t\"time\"\n)\n\nfunc main() {\n\t// Create a cache with a default expiration time of 5 minutes, and which\n\t// purges expired items every 10 minutes\n\tc := cache.New[string](5*time.Minute, 10*time.Minute)\n\n\t// Set the value of the key \"foo\" to \"bar\", with the default expiration time\n\tc.Set(\"foo\", \"bar\", cache.DefaultExpiration)\n\n\t// Set the value of the key \"baz\" to \"lightning\", with no expiration time\n\t// (the item won't be removed until it is re-set, or removed using\n\t// c.Delete(\"baz\")\n\tc.Set(\"baz\", \"lightning\", cache.NoExpiration)\n\n\t// Get the string associated with the key \"foo\" from the cache\n\tfoo, found := c.Get(\"foo\")\n\tif found {\n\t\tfmt.Println(foo)\n\t}\n\n\t// Want performance? Store pointers!\n\tstructCache := cache.New[MyStruct](5*time.Minute, 10*time.Minute)\n\tstructCache.Set(\"foo\", \u0026MyStruct, cache.DefaultExpiration)\n\tif x, found := c.Get(\"foo\"); found {\n\t\tfmt.Println(\")\n\t}\n}\n```\n\nRun this example with `go run examples/main.go`.\n\n## Performance Comparison\nComparison of performance with original [go-cache](https://github.com/patrickmn/go-cache) implementation.\n\nSpoiler alert! The difference is insignificant.\n\n\n\n| \u003csub\u003eTest \u003c/sub\u003e                                        |    \u003csub\u003e [Non generic](https://github.com/patrickmn/go-cache)\u003c/sub\u003e |       |         \u003csub\u003eThis version\u003c/sub\u003e |           |  \n|----------------------------------------------|-----------|-------------|-----------|---------------|\n| \u003csub\u003eBenchmarkCacheGetStringExpiring-8            \u003c/sub\u003e|  \u003csub\u003e29884011\u003c/sub\u003e | \u003csub\u003e41.45 ns/op\u003c/sub\u003e | \u003csub\u003e28318041\u003c/sub\u003e | \u003csub\u003e43.31 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetStringNotExpiring-8         \u003c/sub\u003e|  \u003csub\u003e91891774\u003c/sub\u003e | \u003csub\u003e14.20 ns/op\u003c/sub\u003e | \u003csub\u003e72259294\u003c/sub\u003e | \u003csub\u003e14.02 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetConcurrentExpiring-8        \u003c/sub\u003e|  \u003csub\u003e26299849\u003c/sub\u003e | \u003csub\u003e42.58 ns/op\u003c/sub\u003e | \u003csub\u003e30129078\u003c/sub\u003e | \u003csub\u003e39.53 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetConcurrentNotExpiring-8     \u003c/sub\u003e|  \u003csub\u003e28991383\u003c/sub\u003e | \u003csub\u003e41.25 ns/op\u003c/sub\u003e | \u003csub\u003e30760544\u003c/sub\u003e | \u003csub\u003e38.09 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetManyConcurrentExpiring-8    \u003c/sub\u003e|  \u003csub\u003e55589712\u003c/sub\u003e | \u003csub\u003e44.90 ns/op\u003c/sub\u003e | \u003csub\u003e56991110\u003c/sub\u003e | \u003csub\u003e38.86 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetManyConcurrentNotExpiring-8 \u003c/sub\u003e|  \u003csub\u003e30105078\u003c/sub\u003e | \u003csub\u003e43.98 ns/op\u003c/sub\u003e | \u003csub\u003e46270045\u003c/sub\u003e | \u003csub\u003e41.54 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetStringExpiring-8            \u003c/sub\u003e|  \u003csub\u003e18392893\u003c/sub\u003e | \u003csub\u003e63.41 ns/op\u003c/sub\u003e | \u003csub\u003e17788724\u003c/sub\u003e | \u003csub\u003e61.42 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetStringNotExpiring-8         \u003c/sub\u003e|  \u003csub\u003e46400654\u003c/sub\u003e | \u003csub\u003e28.45 ns/op\u003c/sub\u003e | \u003csub\u003e40226074\u003c/sub\u003e | \u003csub\u003e27.41 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetDelete-8                    \u003c/sub\u003e|  \u003csub\u003e18703620\u003c/sub\u003e | \u003csub\u003e60.75 ns/op\u003c/sub\u003e | \u003csub\u003e18270448\u003c/sub\u003e | \u003csub\u003e59.90 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetDeleteSingleLock-8          \u003c/sub\u003e|  \u003csub\u003e32633755\u003c/sub\u003e | \u003csub\u003e39.34 ns/op\u003c/sub\u003e | \u003csub\u003e32415156\u003c/sub\u003e | \u003csub\u003e36.96 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetStructExpiring-8            \u003c/sub\u003e|  \u003csub\u003e30487856\u003c/sub\u003e | \u003csub\u003e41.60 ns/op\u003c/sub\u003e | \u003csub\u003e26925226\u003c/sub\u003e | \u003csub\u003e40.55 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetStructNotExpiring-8         \u003c/sub\u003e|  \u003csub\u003e91921044\u003c/sub\u003e | \u003csub\u003e13.94 ns/op\u003c/sub\u003e | \u003csub\u003e96379750\u003c/sub\u003e | \u003csub\u003e13.08 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetStructExpiring-8            \u003c/sub\u003e|  \u003csub\u003e13977464\u003c/sub\u003e | \u003csub\u003e86.44 ns/op\u003c/sub\u003e | \u003csub\u003e13364509\u003c/sub\u003e | \u003csub\u003e87.69 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetStructNotExpiring-8         \u003c/sub\u003e|  \u003csub\u003e22749384\u003c/sub\u003e | \u003csub\u003e54.14 ns/op\u003c/sub\u003e | \u003csub\u003e23207397\u003c/sub\u003e | \u003csub\u003e52.58 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheSetFatStructExpiring-8         \u003c/sub\u003e|  \u003csub\u003e11718718\u003c/sub\u003e | \u003csub\u003e103.3 ns/op\u003c/sub\u003e | \u003csub\u003e12051895\u003c/sub\u003e | \u003csub\u003e102.3 ns/op\u003c/sub\u003e |\n| \u003csub\u003eBenchmarkCacheGetFatStructNotExpiring-8      \u003c/sub\u003e|  \u003csub\u003e88695709\u003c/sub\u003e | \u003csub\u003e13.92 ns/op\u003c/sub\u003e | \u003csub\u003e83220014\u003c/sub\u003e | \u003csub\u003e13.76 ns/op\u003c/sub\u003e |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnum30%2Fgo-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnum30%2Fgo-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnum30%2Fgo-cache/lists"}