{"id":20168823,"url":"https://github.com/quangtung97/memtable","last_synced_at":"2025-09-03T02:04:37.356Z","repository":{"id":57629895,"uuid":"383732380","full_name":"QuangTung97/memtable","owner":"QuangTung97","description":"In-memory cache with 'leasing' mechanism","archived":false,"fork":false,"pushed_at":"2021-09-21T04:28:33.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T04:54:20.526Z","etag":null,"topics":["cache","lease"],"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/QuangTung97.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":"2021-07-07T08:46:13.000Z","updated_at":"2022-01-26T00:07:49.000Z","dependencies_parsed_at":"2022-09-26T22:30:19.675Z","dependency_job_id":null,"html_url":"https://github.com/QuangTung97/memtable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/QuangTung97/memtable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuangTung97%2Fmemtable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuangTung97%2Fmemtable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuangTung97%2Fmemtable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuangTung97%2Fmemtable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuangTung97","download_url":"https://codeload.github.com/QuangTung97/memtable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuangTung97%2Fmemtable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273377153,"owners_count":25094528,"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-09-03T02:00:09.631Z","response_time":76,"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":["cache","lease"],"created_at":"2024-11-14T01:10:10.297Z","updated_at":"2025-09-03T02:04:37.301Z","avatar_url":"https://github.com/QuangTung97.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Library for Consistent Cache\n[![Go Report Card](https://goreportcard.com/badge/github.com/quangtung97/memtable)](https://goreportcard.com/report/github.com/quangtung97/memtable)\n[![Coverage Status](https://coveralls.io/repos/github/QuangTung97/memtable/badge.svg?branch=master)](https://coveralls.io/github/QuangTung97/memtable?branch=master)\n\nBased on the [freecache](https://github.com/coocood/freecache) library and the 'leasing' mechanism of the paper\n[Scaling Memcache at Facebook](https://www.usenix.org/system/files/conference/nsdi13/nsdi13-final170_update.pdf).\n\n## Usage\n\n```go\ncacheSize := 100 * 1024 * 1024 // 100MB\ncache := memtable.New(cacheSize)\n\nfor {\n    key := []byte(\"some-key\")\n    result := cache.Get(key)\n    if result.Status == memtable.GetStatusLeaseRejected {\n    \ttime.Sleep(100 * time.Millisecond)\n    \tcontinue\n    }\n    \n    if result.Status == memtable.GetStatusFound {\n    \t// cache hit\n    \tfmt.Println(\"Got value:\", result.Value)\n    \treturn\n    }\n    \n    // cache miss but lease is granted\n    // get data from database\n    value := []byte(\"some-value\")\n    \n    affected := cache.Set(key, result.LeaseID, value)\n    fmt.Println(\"Affected:\", affected)\n    return\n}\n```\n\n## License\n\nThe MIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquangtung97%2Fmemtable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquangtung97%2Fmemtable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquangtung97%2Fmemtable/lists"}