{"id":13365763,"url":"https://github.com/muesli/cache2Go","last_synced_at":"2025-03-12T17:32:03.356Z","repository":{"id":11757936,"uuid":"14290813","full_name":"muesli/cache2go","owner":"muesli","description":"Concurrency-safe Go caching library with expiration capabilities and access counters","archived":false,"fork":false,"pushed_at":"2024-07-02T15:31:52.000Z","size":119,"stargazers_count":2115,"open_issues_count":35,"forks_count":515,"subscribers_count":67,"default_branch":"master","last_synced_at":"2024-10-15T13:21:28.496Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muesli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"muesli"}},"created_at":"2013-11-11T03:45:02.000Z","updated_at":"2024-10-13T16:07:24.000Z","dependencies_parsed_at":"2024-06-18T11:12:02.985Z","dependency_job_id":"8d2571e0-cb0f-48f1-8944-f8014e16f39c","html_url":"https://github.com/muesli/cache2go","commit_stats":{"total_commits":182,"total_committers":14,"mean_commits":13.0,"dds":"0.17582417582417587","last_synced_commit":"518229cd8021d8568e4c6c13743bb050dc1f3a05"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fcache2go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fcache2go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fcache2go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muesli%2Fcache2go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muesli","download_url":"https://codeload.github.com/muesli/cache2go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221305494,"owners_count":16795145,"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":["hacktoberfest"],"created_at":"2024-07-30T00:01:13.399Z","updated_at":"2024-10-24T10:30:54.692Z","avatar_url":"https://github.com/muesli.png","language":"Go","readme":"# cache2go\n\n[![Latest Release](https://img.shields.io/github/release/muesli/cache2go.svg)](https://github.com/muesli/cache2go/releases)\n[![Build Status](https://github.com/muesli/cache2go/workflows/build/badge.svg)](https://github.com/muesli/cache2go/actions)\n[![Coverage Status](https://coveralls.io/repos/github/muesli/cache2go/badge.svg?branch=master)](https://coveralls.io/github/muesli/cache2go?branch=master)\n[![Go ReportCard](https://goreportcard.com/badge/muesli/cache2go)](https://goreportcard.com/report/muesli/cache2go)\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://pkg.go.dev/github.com/muesli/cache2go)\n\nConcurrency-safe golang caching library with expiration capabilities.\n\n## Installation\n\nMake sure you have a working Go environment (Go 1.2 or higher is required).\nSee the [install instructions](https://golang.org/doc/install.html).\n\nTo install cache2go, simply run:\n\n    go get github.com/muesli/cache2go\n\nTo compile it from source:\n\n    cd $GOPATH/src/github.com/muesli/cache2go\n    go get -u -v\n    go build \u0026\u0026 go test -v\n\n## Example\n```go\npackage main\n\nimport (\n\t\"github.com/muesli/cache2go\"\n\t\"fmt\"\n\t\"time\"\n)\n\n// Keys \u0026 values in cache2go can be of arbitrary types, e.g. a struct.\ntype myStruct struct {\n\ttext     string\n\tmoreData []byte\n}\n\nfunc main() {\n\t// Accessing a new cache table for the first time will create it.\n\tcache := cache2go.Cache(\"myCache\")\n\n\t// We will put a new item in the cache. It will expire after\n\t// not being accessed via Value(key) for more than 5 seconds.\n\tval := myStruct{\"This is a test!\", []byte{}}\n\tcache.Add(\"someKey\", 5*time.Second, \u0026val)\n\n\t// Let's retrieve the item from the cache.\n\tres, err := cache.Value(\"someKey\")\n\tif err == nil {\n\t\tfmt.Println(\"Found value in cache:\", res.Data().(*myStruct).text)\n\t} else {\n\t\tfmt.Println(\"Error retrieving value from cache:\", err)\n\t}\n\n\t// Wait for the item to expire in cache.\n\ttime.Sleep(6 * time.Second)\n\tres, err = cache.Value(\"someKey\")\n\tif err != nil {\n\t\tfmt.Println(\"Item is not cached (anymore).\")\n\t}\n\n\t// Add another item that never expires.\n\tcache.Add(\"someKey\", 0, \u0026val)\n\n\t// cache2go supports a few handy callbacks and loading mechanisms.\n\tcache.SetAboutToDeleteItemCallback(func(e *cache2go.CacheItem) {\n\t\tfmt.Println(\"Deleting:\", e.Key(), e.Data().(*myStruct).text, e.CreatedOn())\n\t})\n\n\t// Remove the item from the cache.\n\tcache.Delete(\"someKey\")\n\n\t// And wipe the entire cache table.\n\tcache.Flush()\n}\n```\n\nTo run this example, go to examples/mycachedapp/ and run:\n\n    go run mycachedapp.go\n\nYou can find a [few more examples here](https://github.com/muesli/cache2go/tree/master/examples).\nAlso see our test-cases in cache_test.go for further working examples.\n","funding_links":["https://github.com/sponsors/muesli"],"categories":["数据库","數據庫"],"sub_categories":["高级控制台界面","高級控制台界面"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuesli%2Fcache2Go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuesli%2Fcache2Go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuesli%2Fcache2Go/lists"}