{"id":13563911,"url":"https://github.com/kofalt/go-memoize","last_synced_at":"2026-01-17T02:40:38.206Z","repository":{"id":48514161,"uuid":"160632400","full_name":"kofalt/go-memoize","owner":"kofalt","description":"An easy, no-frills memoizer for Go. Cache your expensive function calls.","archived":false,"fork":false,"pushed_at":"2024-07-06T22:49:40.000Z","size":28,"stargazers_count":120,"open_issues_count":0,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T20:37:41.598Z","etag":null,"topics":["cache","golang","memoize"],"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/kofalt.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-12-06T06:54:13.000Z","updated_at":"2025-02-15T12:48:01.000Z","dependencies_parsed_at":"2024-11-04T16:34:26.806Z","dependency_job_id":"335c03bf-ba9b-489b-adff-804a9a0ceb58","html_url":"https://github.com/kofalt/go-memoize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kofalt/go-memoize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kofalt%2Fgo-memoize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kofalt%2Fgo-memoize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kofalt%2Fgo-memoize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kofalt%2Fgo-memoize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kofalt","download_url":"https://codeload.github.com/kofalt/go-memoize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kofalt%2Fgo-memoize/sbom","scorecard":{"id":565832,"data":{"date":"2025-08-11","repo":{"name":"github.com/kofalt/go-memoize","commit":"9e5eb99a0f2aeb80e6269c827209520bc7481c1f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/12 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":"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":"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/build.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/kofalt/go-memoize/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/kofalt/go-memoize/build.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction 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":"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":"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/build.yml: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":"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.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt: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 'master'"],"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":"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 7 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"}}]},"last_synced_at":"2025-08-20T14:57:31.765Z","repository_id":48514161,"created_at":"2025-08-20T14:57:31.768Z","updated_at":"2025-08-20T14:57:31.768Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"online","status_checked_at":"2026-01-17T02:00:07.808Z","response_time":85,"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","golang","memoize"],"created_at":"2024-08-01T13:01:24.472Z","updated_at":"2026-01-17T02:40:38.181Z","avatar_url":"https://github.com/kofalt.png","language":"Go","funding_links":[],"categories":["\u003ca name=\"Go\"\u003e\u003c/a\u003eGo","Go"],"sub_categories":[],"readme":"# go-memoize\n\nThere wasn't a decent [memoizer](https://wikipedia.org/wiki/Memoization) for Golang out there, so I lashed two nice libraries together and made one.\n\nDead-simple. Safe for concurrent use.\n\n[![Reference](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/kofalt/go-memoize)\n[![Linter](https://goreportcard.com/badge/github.com/kofalt/go-memoize?style=flat-square)](https://goreportcard.com/report/github.com/kofalt/go-memoize)\n[![Build status](https://github.com/kofalt/go-memoize/workflows/Build/badge.svg)](https://github.com/kofalt/go-memoize/actions)\n\n## Project status\n\n**Complete.** Latest commit timestamp might be old - that's okay.\n\nGo-memoize has been in production for a few years, and has yet to burn the house down.\n\n## Usage\n\nCache expensive function calls in memory, with a configurable timeout and purge interval:\n\n```golang\nimport (\n\t\"time\"\n\n\t\"github.com/kofalt/go-memoize\"\n)\n\n// Any expensive call that you wish to cache\nexpensive := func() (any, error) {\n\ttime.Sleep(3 * time.Second)\n\treturn \"some data\", nil\n}\n\n// Cache expensive calls in memory for 90 seconds, purging old entries every 10 minutes.\ncache := memoize.NewMemoizer(90*time.Second, 10*time.Minute)\n\n// This will call the expensive func\nresult, err, cached := cache.Memoize(\"key1\", expensive)\n\n// This will be cached\nresult, err, cached = cache.Memoize(\"key1\", expensive)\n\n// This uses a new cache key, so expensive is called again\nresult, err, cached = cache.Memoize(\"key2\", expensive)\n```\n\nIn the example above, `result` is:\n1. the return value from your function if `cached` is false, or\n1. a previously stored value if `cached` is true.\n\nAll the hard stuff is punted to [go-cache](https://github.com/patrickmn/go-cache) and [sync/singleflight](https://github.com/golang/sync), I just lashed them together.\u003cbr/\u003e\nNote that `cache.Storage` is exported, so you can use underlying features such as [Flush](https://godoc.org/github.com/patrickmn/go-cache#Cache.Flush) or [SaveFile](https://godoc.org/github.com/patrickmn/go-cache#Cache.SaveFile).\n\n### Type safety\n\nThe default usage stores and returns an `any` type.\u003cbr/\u003e\nIf you wants to store \u0026 retrieve a specific type, use `Call` instead:\n\n```golang\nimport (\n\t\"time\"\n\n\t\"github.com/kofalt/go-memoize\"\n)\n\n// Same example as above, but this func returns a string!\nexpensive := func() (string, error) {\n\ttime.Sleep(3 * time.Second)\n\treturn \"some data\", nil\n}\n\n// Same as before\ncache := memoize.NewMemoizer(90*time.Second, 10*time.Minute)\n\n// This will call the expensive func, and return a string.\nresult, err, cached := memoize.Call(cache, \"key1\", expensive)\n\n// This will be cached\nresult, err, cached = memoize.Call(cache, \"key1\", expensive)\n\n// This uses a new cache key, so expensive is called again\nresult, err, cached = memoize.Call(cache, \"key2\", expensive)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkofalt%2Fgo-memoize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkofalt%2Fgo-memoize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkofalt%2Fgo-memoize/lists"}