{"id":17355279,"url":"https://github.com/moethu/go-access-cache","last_synced_at":"2025-10-12T05:42:13.967Z","repository":{"id":142506830,"uuid":"277087739","full_name":"moethu/go-access-cache","owner":"moethu","description":"Go Access Cache: keeping most requested elements in memory","archived":false,"fork":false,"pushed_at":"2020-07-04T11:18:23.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-12T05:42:13.234Z","etag":null,"topics":["caching","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moethu.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}},"created_at":"2020-07-04T10:26:41.000Z","updated_at":"2024-08-29T19:39:25.000Z","dependencies_parsed_at":"2024-06-19T14:38:53.433Z","dependency_job_id":"3851e587-e918-4fd5-8fc1-70e35a2443a6","html_url":"https://github.com/moethu/go-access-cache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/moethu/go-access-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moethu%2Fgo-access-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moethu%2Fgo-access-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moethu%2Fgo-access-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moethu%2Fgo-access-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moethu","download_url":"https://codeload.github.com/moethu/go-access-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moethu%2Fgo-access-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010328,"owners_count":26084738,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"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":["caching","golang"],"created_at":"2024-10-15T17:42:50.587Z","updated_at":"2025-10-12T05:42:13.947Z","avatar_url":"https://github.com/moethu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Access Cache\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/moethu/go-access-cache)](https://goreportcard.com/report/github.com/moethu/go-access-cache)\n\n\nA simple in memory cache with a maximum byte size keeping most and recent requested elements in memory while rotating rarely requested elements out.\n\n### Example\n\n```go\nm := accesscache.NewAccessCache(60)\n\n// Adding first item, cache size will be 28\nm.Set(\"key-a\", \"first string\")\nlog.Println(\"Highest Prio Item:\", m.GetLastViewedKey(), \"Cache Size:\", m.GetCacheSize())\n\n// Adding second item, cache size will be 57\nm.Set(\"key-b\", \"second string\")\nlog.Println(\"Highest Prio Item:\", m.GetLastViewedKey(), \"Cache Size:\", m.GetCacheSize())\n\n// Requesting first item, it get the highest prio, cache size remains 57\nm.Get(\"key-a\")\nlog.Println(\"Highest Prio Item:\", m.GetLastViewedKey(), \"Cache Size:\", m.GetCacheSize())\n\n// Adding third item, lowest prio item gets rotated out because cache size \u003e 60\n// third item get highest prio, cache size is at 56\nm.Set(\"key-c\", \"third string\")\nlog.Println(\"Highest Prio Item:\", m.GetLastViewedKey(), \"Cache Size:\", m.GetCacheSize())\n\n// Requesting first item, wich again gets the highest prio, cache size is at 56\n// containing only the first and the second item\nm.Get(\"key-a\")\nlog.Println(\"Highest Prio Item:\", m.GetLastViewedKey(), \"Cache Size:\", m.GetCacheSize())\n```\n\n### Usage\n\ninstantiate new access cache with a size of 1024 bytes\n```go\nm := NewAccessCache(1024)\n```\n\nadd value 42 to cache using a unique key \"mykey\"\n```go\nm.Set(\"mykey\", 42)\n```\n\nretrieve value from cache by key \"mykey\"\n```go\nvalue, exists = m.Get(\"mykey\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoethu%2Fgo-access-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoethu%2Fgo-access-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoethu%2Fgo-access-cache/lists"}