{"id":17335327,"url":"https://github.com/shaovie/ttlcache","last_synced_at":"2025-04-06T11:43:18.990Z","repository":{"id":180882895,"uuid":"665856061","full_name":"shaovie/ttlcache","owner":"shaovie","description":"An Efficient In-Process Object Caching Library for Managing Lifecycles","archived":false,"fork":false,"pushed_at":"2023-09-21T08:56:13.000Z","size":10,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T17:21:16.248Z","etag":null,"topics":["cache","go","golang","memcache","ttl-cache"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shaovie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-07-13T06:47:47.000Z","updated_at":"2023-07-16T17:15:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"9621466b-4bde-4545-be44-67c0dd8f91b6","html_url":"https://github.com/shaovie/ttlcache","commit_stats":null,"previous_names":["shaovie/ttlcache"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaovie%2Fttlcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaovie%2Fttlcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaovie%2Fttlcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaovie%2Fttlcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaovie","download_url":"https://codeload.github.com/shaovie/ttlcache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478236,"owners_count":20945262,"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":["cache","go","golang","memcache","ttl-cache"],"created_at":"2024-10-15T15:08:53.327Z","updated_at":"2025-04-06T11:43:18.961Z","avatar_url":"https://github.com/shaovie.png","language":"Go","readme":"## ttlcache\n\n`ttlcache` is an in-process object caching library designed specifically for managing the caching and automatic release of objects with lifecycles. The cache operates on a time-based expiration mechanism, measured in seconds, and utilizes timestamp caching to avoid real-time system time retrieval. This significantly improves efficiency. Object storage employs sharding techniques to reduce concurrent access competition.\n\nUsage:\n```\nimport \"github.com/shaovie/ttlcache\"\n\nfunc main() {\n\tcache := ttlcache.New(ttlcache.BucketsCount(512),\n\t\tttlcache.BucketsMapPreAllocSize(256),\n\t\tttlcache.CleanInterval(10),\n\t)\n\tcache.Set(\"ttlcache\", \"nb\", 1/*second*/) // The lifecycle is 1 second\n\tval, found := cache.Get(\"ttlcache\")\n\tif !found {\n\t\tfmt.Println(\"set val error\")\n\t\treturn\n\t}\n\ttime.Sleep(time.Millisecond * 1500)\n\t_, found = cache.Get(\"ttlcache\")\n\tif !found {\n\t\tfmt.Println(\"expired\")\n\t}\n}\n```\n\nUsage Reference: `ttlcache_bench_test.go`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaovie%2Fttlcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaovie%2Fttlcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaovie%2Fttlcache/lists"}