{"id":25526249,"url":"https://github.com/exbotanical/tenure-go","last_synced_at":"2026-01-12T08:00:13.185Z","repository":{"id":57596525,"uuid":"375492675","full_name":"exbotanical/tenure-go","owner":"exbotanical","description":"A thread-safe, hash-mapped LRU cache instance","archived":false,"fork":false,"pushed_at":"2021-06-11T00:25:52.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T09:04:26.528Z","etag":null,"topics":["in-memory-caching","least-recently-used","lru-cache","lru-replacement-algorithm","thread-safe-cache"],"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/exbotanical.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-06-09T21:23:33.000Z","updated_at":"2021-06-11T00:25:55.000Z","dependencies_parsed_at":"2022-09-26T19:53:09.263Z","dependency_job_id":null,"html_url":"https://github.com/exbotanical/tenure-go","commit_stats":null,"previous_names":["matthewzito/tenure-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/exbotanical/tenure-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Ftenure-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Ftenure-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Ftenure-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Ftenure-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exbotanical","download_url":"https://codeload.github.com/exbotanical/tenure-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exbotanical%2Ftenure-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["in-memory-caching","least-recently-used","lru-cache","lru-replacement-algorithm","thread-safe-cache"],"created_at":"2025-02-19T21:17:05.069Z","updated_at":"2026-01-12T08:00:12.850Z","avatar_url":"https://github.com/exbotanical.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tenure-go\n\n`Tenure-go` is a thread-safe LRU cache instance that uses hashmap lookups and an Open Doubly Linked List to enact the [Least-Recently Used algorithm](https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)).\n\n`Tenure-go`'s internal cache utilizes the Go's sync/mutex locking mechanism to ensure thread-safety.\n\n## Install\n\n```bash\ngo get -u github.com/MatthewZito/tenure-go\n```\n\n```go\nimport (\n\ttenure \"github.com/MatthewZito/tenure-go\"\n)\n\nlru, err := New(10, cb)\n\nlru.Put(\"key\", \"value\")\n```\n\n--\n\n## Usage\n\n#### type Callback\n\n```go\ntype Callback func(key interface{}, value interface{})\n```\n\n\n#### type LRUCache\n\n```go\ntype LRUCache struct {\n}\n```\n\n\n#### func  New\n\n```go\nfunc New(bufCap int, onItemEvicted Callback) (*LRUCache, error)\n```\nNew initializes a new LRU cache with a buffer capacity of `bufCap` It accepts as\na second parameter a callback to be invoked upon successful invocation of the\nLeast Recently-Used cache policy i.e. when a key/value pair is removed All\ntransactions utilize locks and are therefore thread-safe\n\n#### func (*LRUCache) AdjustCapacity\n\n```go\nfunc (lc *LRUCache) AdjustCapacity(bufCap int) (numEvicted int)\n```\nAdjustCapacity resizes the cache capacity Invoking this transaction will evict\nall least recently-used items to adjust the cache, where necessary\n\n#### func (*LRUCache) Capacity\n\n```go\nfunc (lc *LRUCache) Capacity() int\n```\nCapacity returns the current maximum buffer capacity of the cache\n\n#### func (*LRUCache) Del\n\n```go\nfunc (lc *LRUCache) Del(key interface{}) (wasDeleted bool)\n```\nDel deletes an item corresponding to a given key from the cache, if extant A\nboolean flag is returned, indicating whether of not the transaction occurred\n\n#### func (*LRUCache) Drop\n\n```go\nfunc (lc *LRUCache) Drop()\n```\nDrop drops all items from the cache\n\n#### func (*LRUCache) Get\n\n```go\nfunc (lc *LRUCache) Get(key interface{}) (value interface{}, ok bool)\n```\nGet attempts to retrieve the value for the given key from the cache Returns the\ncorresponding value and true if extant; else, returns nil, false Get\ntransactions will move the item to the head of the cache, designating it as most\nrecently-used\n\n#### func (*LRUCache) Has\n\n```go\nfunc (lc *LRUCache) Has(key interface{}) (ok bool)\n```\nHas returns a boolean flag verifying the existence (or lack thereof) of a given\nkey in the cache without enacting the eviction policy\n\n#### func (*LRUCache) Keys\n\n```go\nfunc (lc *LRUCache) Keys() []interface{}\n```\nKeys returns a slice of the keys currently extant in the cache\n\n#### func (*LRUCache) LeastRecentlyUsed\n\n```go\nfunc (lc *LRUCache) LeastRecentlyUsed() (key interface{}, value interface{})\n```\nLeastRecentlyUsed returns the least recently-used key / value pair, or nil if\nnot extant\n\n#### func (*LRUCache) Put\n\n```go\nfunc (lc *LRUCache) Put(key, value interface{}) (wasEvicted bool)\n```\nPut adds or inserts a given key / value pair into the cache Put transactions\nwill move the key to the head of the cache, designating it as 'most\nrecently-used' If the cache has reached the specified capacity, Put transactions\nwill also enact the eviction policy thereby removing the least recently-used\nitem Returns a boolean flag indicating whether an eviction occurred\n\n#### func (*LRUCache) Size\n\n```go\nfunc (lc *LRUCache) Size() int\n```\nSize returns the current size of the cache\n\n#### type LRUController\n\n```go\ntype LRUController interface {\n\tGet(key interface{}) (value interface{}, ok bool)\n\tPut(key, value interface{}) (wasEvicted bool)\n\tDel(key interface{}) (wasDeleted bool)\n\tKeys() []interface{}\n\tPeek(key interface{}) (value interface{})\n\tHas(key interface{}) (ok bool)\n\tPurge()\n\tSize() int\n\tAdjustCapacity(bufCap int) (numEvicted int)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexbotanical%2Ftenure-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexbotanical%2Ftenure-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexbotanical%2Ftenure-go/lists"}