{"id":26197427,"url":"https://github.com/golift/cache","last_synced_at":"2026-04-13T01:41:20.177Z","repository":{"id":53676056,"uuid":"521146734","full_name":"golift/cache","owner":"golift","description":"In-memory cache Go module. High performance, integrated statistics. ","archived":false,"fork":false,"pushed_at":"2026-04-12T23:37:34.000Z","size":93,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-13T01:21:19.066Z","etag":null,"topics":["cache","go","golang","memcached","memcached-server"],"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/golift.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-08-04T06:17:36.000Z","updated_at":"2026-04-10T20:04:52.000Z","dependencies_parsed_at":"2024-04-25T02:44:34.659Z","dependency_job_id":"3ae8e83e-13a1-4021-8a1c-038786db7a7e","html_url":"https://github.com/golift/cache","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/golift/cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golift","download_url":"https://codeload.github.com/golift/cache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fcache/sbom","scorecard":{"id":434843,"data":{"date":"2025-08-11","repo":{"name":"github.com/golift/cache","commit":"3d88fa920289578891dbba10ab4aad55b40420f8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/9 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":"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":"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":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":"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/codetests.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codetests.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codetests.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codetests.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/codetests.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codetests.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codetests.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/codetests.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/golift/cache/codetests.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party 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":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/codetests.yml:7","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":"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":"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":"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":"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":"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":"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 23 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-19T04:21:09.048Z","repository_id":53676056,"created_at":"2025-08-19T04:21:09.048Z","updated_at":"2025-08-19T04:21:09.048Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31736723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T22:19:12.206Z","status":"ssl_error","status_checked_at":"2026-04-12T22:18:33.088Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["cache","go","golang","memcached","memcached-server"],"created_at":"2025-03-12T02:27:05.057Z","updated_at":"2026-04-13T01:41:20.167Z","avatar_url":"https://github.com/golift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cache\n\n[![Go Reference](https://pkg.go.dev/badge/golift.io/cache.svg)](https://pkg.go.dev/golift.io/cache)\n[![Go Report Card](https://goreportcard.com/badge/golift.io/cache)](https://goreportcard.com/report/golift.io/cache)\n[![MIT License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/golift/cache/blob/master/LICENSE)\n[![discord](https://badgen.net/badge/icon/Discord?color=0011ff\u0026label\u0026icon=https://simpleicons.now.sh/discord/eee \"GoLift Discord\")](https://golift.io/discord)\n\nThis module provides a small in-memory key/value cache for Go.\n\n- **Concurrency:** Each **shard** has its own `sync.RWMutex` over a `map[string]*Item`. `Get` takes a **read** lock on that\n  shard; `Save`, `Update`, `Delete`, and the pruner take the **write** lock. Hit/miss and per-item access metadata use atomics\n  so reads do not serialize on the mutex. Shards are looked up via `sync.Map` (`uint32` index → shard), populated at startup\n  when `Config.Shards` is greater than 1. `List` takes read locks per shard; `Stats` aggregates atomic counters and per-shard\n  item counts (under contention, counter snapshots can be briefly inconsistent across fields).\n- **Background work:** By default each operation uses `time.Now()` directly. If `RequestAccuracy` is set above\n  100ms, one goroutine also refreshes a shared clock on that interval (fewer `time.Now()` calls on hot paths).\n  The optional pruner runs on `PruneInterval`.\n- **Metrics:** Hit/miss and other counters are exposed for `expvar` or your own metrics pipeline.\n- **Sharding:** Optional `Config.Shards` (default 1) partitions keys across multiple maps using FNV-1a 64-bit `hash(key) % Shards`\n  (capped at 65536). Use this to reduce mutex contention under high concurrency.\n\nItems can be marked prunable or not. Prunable entries are removed after they have not been retrieved within `PruneAfter`.\nNon-prunable entries use a separate maximum idle duration (`MaxUnused`).\n\nI wrote this to cache data from MySQL queries for an [nginx auth proxy](https://github.com/Notifiarr/mysql-auth-proxy).\nIt is also useful as a simple global in-process store.\n\n## Example: basic use\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"golift.io/cache\"\n)\n\nfunc main() {\n\tc := cache.New(cache.Config{})\n\tdefer c.Stop(true)\n\n\tc.Save(\"user:42\", \"Ada\", cache.Options{})\n\n\titem := c.Get(\"user:42\")\n\tif item != nil {\n\t\tfmt.Println(\"value:\", item.Data)\n\t}\n}\n```\n\n## Example: pruning and stats\n\n```go\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"golift.io/cache\"\n)\n\nfunc exampleStats() {\n\tc := cache.New(cache.Config{\n\t\tPruneInterval: 5 * time.Minute,\n\t\tPruneAfter:    10 * time.Minute,\n\t\tMaxUnused:     24 * time.Hour,\n\t})\n\tdefer c.Stop(false)\n\n\tc.Save(\"session:1\", \"opaque-token\", cache.Options{Prune: true})\n\n\tstats := c.Stats()\n\tfmt.Println(\"hits:\", stats.Hits, \"size:\", stats.Size)\n}\n```\n\nSee also the package example in [cache_test.go](cache_test.go).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolift%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Fcache/lists"}