{"id":18673102,"url":"https://github.com/vicanso/lru-ttl","last_synced_at":"2025-06-12T12:38:49.492Z","repository":{"id":57522062,"uuid":"248222801","full_name":"vicanso/lru-ttl","owner":"vicanso","description":"lru cache with ttl","archived":false,"fork":false,"pushed_at":"2022-04-24T02:58:06.000Z","size":106,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T10:07:12.473Z","etag":null,"topics":["lru-cache","ttl-cache"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vicanso.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}},"created_at":"2020-03-18T12:15:39.000Z","updated_at":"2022-03-18T02:13:58.000Z","dependencies_parsed_at":"2022-08-26T23:41:08.473Z","dependency_job_id":null,"html_url":"https://github.com/vicanso/lru-ttl","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/vicanso/lru-ttl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicanso%2Flru-ttl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicanso%2Flru-ttl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicanso%2Flru-ttl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicanso%2Flru-ttl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vicanso","download_url":"https://codeload.github.com/vicanso/lru-ttl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vicanso%2Flru-ttl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259466694,"owners_count":22862367,"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":["lru-cache","ttl-cache"],"created_at":"2024-11-07T09:13:58.879Z","updated_at":"2025-06-12T12:38:49.462Z","avatar_url":"https://github.com/vicanso.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lru-ttl\n\n[![Build Status](https://github.com/vicanso/lru-ttl/workflows/Test/badge.svg)](https://github.com/vicanso/lru-ttl/actions)\n\nLRU cache with ttl. It's useful for short ttl cache. \nL2Cache use lru cache as first cache, and slow cache as second cache. Lru cache should be set max entries for less memory usage but faster, slow cache is slower but larger capacity.\n\n## LRU TTL\n\n\n```go\ncache := lruttl.New(1000, 60 * time.Second)\ncache.Add(\"tree.xie\", \"my data\")\ndata, ok := cache.Get(\"tree.xie\")\ncache.Remove(\"tree.xie\")\ncache.Add(\"tree.xie\", \"my data\", time.Second)\n```\n\n## L2Cache\n\n```go\n// redisCache\nl2 := lruttl.NewL2Cache(redisCache, 200, 10 * time.Minute)\nctx := context.Background()\nerr := l2.Set(ctx, \"key\", \u0026map[string]string{\n    \"name\": \"test\",\n})\nfmt.Println(err)\nm := make(map[string]string)\nerr = l2.Get(ctx, \"key\", \u0026m)\nfmt.Println(err)\nfmt.Println(m)\n```\n\n## Ring\n\n```go\nringCache := lruttl.NewRing(lruttl.RingCacheParams{\n    Size:       10,\n    MaxEntries: 1000,\n    DefaultTTL: time.Minute,\n})\nlruCache := ringCache(\"key\")\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvicanso%2Flru-ttl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvicanso%2Flru-ttl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvicanso%2Flru-ttl/lists"}