{"id":37124205,"url":"https://github.com/turboezh/heapcache","last_synced_at":"2026-01-14T14:20:32.809Z","repository":{"id":57593204,"uuid":"84444359","full_name":"turboezh/heapcache","owner":"turboezh","description":"Priority queue (heap) based cache with 'priority' evict policy","archived":false,"fork":false,"pushed_at":"2019-02-06T15:17:56.000Z","size":37,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-11T19:10:40.991Z","etag":null,"topics":["cache","heap","priority","priority-queue"],"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/turboezh.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":"2017-03-09T13:21:01.000Z","updated_at":"2023-07-11T19:10:40.991Z","dependencies_parsed_at":"2022-09-12T16:20:50.949Z","dependency_job_id":null,"html_url":"https://github.com/turboezh/heapcache","commit_stats":null,"previous_names":[],"tags_count":9,"template":null,"template_full_name":null,"purl":"pkg:github/turboezh/heapcache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboezh%2Fheapcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboezh%2Fheapcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboezh%2Fheapcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboezh%2Fheapcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turboezh","download_url":"https://codeload.github.com/turboezh/heapcache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turboezh%2Fheapcache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28422676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"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":["cache","heap","priority","priority-queue"],"created_at":"2026-01-14T14:20:32.037Z","updated_at":"2026-01-14T14:20:32.795Z","avatar_url":"https://github.com/turboezh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# heapcache\n[![Build Status](https://travis-ci.org/turboezh/heapcache.svg)](https://travis-ci.org/turboezh/heapcache)\n[![GitHub release](https://img.shields.io/github/release/turboezh/heapcache.svg)](https://github.com/turboezh/heapcache/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/turboezh/heapcache)](https://goreportcard.com/report/github.com/turboezh/heapcache)\n[![Maintainability](https://api.codeclimate.com/v1/badges/de484103003b548529f0/maintainability)](https://codeclimate.com/github/turboezh/heapcache/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/de484103003b548529f0/test_coverage)](https://codeclimate.com/github/turboezh/heapcache/test_coverage)\n![Downloads](https://img.shields.io/github/downloads/turboezh/heapcahce/total.svg)\n[![GoDoc](https://godoc.org/github.com/turboezh/heapcache?status.svg)](https://godoc.org/github.com/turboezh/heapcache)\n\nThis cache implementation is based on priority queue (see [Heap](https://golang.org/pkg/container/heap/)).\nIt uses user-defined comparator to evaluate priorities of cached items. Items with lowest priorities will be evicted first.\n\nFeatures:\n - simple standard data structure;\n - no write locks on get operations;\n - capacity may be changed at any time.\n\n# Requirements\nGo \u003e= 1.11\n\n# Documentation\nhttps://godoc.org/github.com/turboezh/heapcache\n\n# Examples\n\n## Cache\n```go\ntype Foo struct {\n    Value int\n    Timestamp time.Time\n}\n\nitem1 := Foo{10, time.Now()}\nitem2 := Foo{20, time.Now().Add(time.Second)}\n\ncache := New(10, func(a, b interface{}) bool {\n    return a.(*Foo).Timestamp.Before(b.(*Foo).Timestamp)\n})\n```\n\n## Add item\n```go\ncache.Add(\"one\", \u0026item1)\ncache.Add(\"two\", \u0026item2)\n\n```\n\n## Get item\n```go\nitem, exists := cache.Get(\"one\")\nif !exists {\n    // `foo` doesn't exists in cache\n    // `item` is nil\n}\n// cache returns `interface{}` so we need to assert type (if need so)\nitem = item.(*Foo) // = \u0026item1\n```\n\n## Check item\n```go\n// check if cache contain all keys \nok := cache.All(\"one\", \"two\")\n\n// check if cache contain any of keys \nok := cache.Any(\"one\", \"two\")\n```\n\n## Remove item\n```go\n// Remove returns false if there is no item in cache\nwasRemoved := cache.Remove(\"one\")\n```\n\n## Support on Beerpay\nHey dude! Help me out for a couple of :beers:!\n\n[![Beerpay](https://beerpay.io/turboezh/heapcache/badge.svg?style=beer-square)](https://beerpay.io/turboezh/heapcache)  [![Beerpay](https://beerpay.io/turboezh/heapcache/make-wish.svg?style=flat-square)](https://beerpay.io/turboezh/heapcache?focus=wish)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturboezh%2Fheapcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturboezh%2Fheapcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturboezh%2Fheapcache/lists"}