{"id":13411808,"url":"https://github.com/mdaliyan/icache","last_synced_at":"2025-12-30T03:37:52.688Z","repository":{"id":39916259,"uuid":"157554169","full_name":"mdaliyan/icache","owner":"mdaliyan","description":"A High Performance, Generic, thread-safe, zero-dependency, key-value, in-memory cache","archived":false,"fork":false,"pushed_at":"2024-06-10T09:26:52.000Z","size":81,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:48:56.915Z","etag":null,"topics":["cache","generic","go","golang","in-memory-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/mdaliyan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2018-11-14T13:38:27.000Z","updated_at":"2024-07-25T23:19:49.000Z","dependencies_parsed_at":"2024-06-19T10:07:25.995Z","dependency_job_id":null,"html_url":"https://github.com/mdaliyan/icache","commit_stats":{"total_commits":68,"total_committers":4,"mean_commits":17.0,"dds":0.3529411764705882,"last_synced_commit":"d540f4c167d10c627fc16cf62a56fce996b7136e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdaliyan%2Ficache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdaliyan%2Ficache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdaliyan%2Ficache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdaliyan%2Ficache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdaliyan","download_url":"https://codeload.github.com/mdaliyan/icache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618666,"owners_count":20320273,"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":["cache","generic","go","golang","in-memory-cache"],"created_at":"2024-07-30T20:01:17.118Z","updated_at":"2025-12-30T03:37:52.644Z","avatar_url":"https://github.com/mdaliyan.png","language":"Go","funding_links":[],"categories":["Database","Data Integration Frameworks","数据库"],"sub_categories":["Caches","缓存"],"readme":"# icache\n\n![example workflow](https://github.com/mdaliyan/icache/actions/workflows/test.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/mdaliyan/icache/badge.svg?branch=master)](https://coveralls.io/github/mdaliyan/icache?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mdaliyan/icache/v2)](https://goreportcard.com/report/github.com/mdaliyan/icache/v2)\n[![Go Reference](https://pkg.go.dev/badge/github.com/mdaliyan/icache/v2.svg)](https://pkg.go.dev/github.com/mdaliyan/icache/v2)\n[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat)](https://raw.githubusercontent.com/labstack/echo/master/LICENSE)\n\nicache is a no-dependency, generic support cache library for Go with high concurrent access performance.\nicache _doean't require serialization_, so the benchmark report you see at the bottom of the page\nis what you get at the end, there is no need to marshal and unmarshal anything and waste your\nvaluable resources.\n\n## Features\n- **Thread safe**: icache stores the data in multiple shards and uses a separate mutex for each shard.\n- **Generics**: Using generics makes it type-safe.\n- **Tags**: icache supports tags for entries and entries with the shared tags can be dropped at the same time.\n- **Pointer friendly**: icache stores data as is. any object can be stored in icache, even pointers.\n- **TTL**: ttl can be set to any thing from 1 seconds to infinity.\n\n## Installation\n\nicache v2 requires go v1.8.0 and above.\n```bash\ngo get github.com/mdaliyan/icache/v2\n```\n\n### previous version for Go \u003c 1.18\n\nicache v1 is compatible with Go \u003c `1.18`, and it also doean't require serialization.\nit uses reflections to make sure about your data type.\n\nFollow instructions at [version v1.x.x](https://github.com/mdaliyan/icache/tree/v1) for installation and usage. \nV1 will be maintained separately.\n\n## Usage\n\n```go \n// make a new Pot:\n// - to store user structs \n// - with expiration time of 1 Hour\nvar pot = icache.NewPot[user](\n          icache.WithTTL(time.Hour),\n    )\n\nvar User = user{\n    ID:   \"foo\",\n    Name: \"John Doe\",\n    Age:  30,\n}\n\n// set user to \"foo\" key\npot.Set(\"foo\", User)\n\n// get the user previously set to \"foo\" key into user1 \nuser1, err := pot.Get(\"foo\")\n\n// you also can add tags to your entries\npot.Set(\"foo\", User, \"tag1\", \"tag2\")\npot.Set(\"faa\", User, \"tag1\")\npot.Set(\"fom\", User, \"tag3\")\n\n// and delete multiple entries at once\npot.DropTags(\"tag1\")\n```\n\n## Invalidation Strategies\n- By **Key**\n- By **Tag**\n- By **TTL**: Using the `WithTTL()` option.\n\n## Benchmarks\n```bash\ngoos: darwin\ngoarch: amd64\npkg: github.com/mdaliyan/icache/v2\ncpu: Intel(R) Core(TM) i7-8557U CPU @ 1.70GHz\nBenchmarkICache\nBenchmarkICache-8             \t9570999\t    118.1 ns/op\t   0 B/op\t  0 allocs/op\nBenchmarkICacheConcurrent\nBenchmarkICacheConcurrent-8   \t6117471\t    191.4 ns/op\t   0 B/op\t  0 allocs/op\n```\n\n## Plans for later\n- Different invalidation Strategies can be added if it's needed. \n- Maybe Remote sync\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdaliyan%2Ficache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdaliyan%2Ficache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdaliyan%2Ficache/lists"}