{"id":18989148,"url":"https://github.com/oogway/go-cache","last_synced_at":"2025-04-22T11:08:14.405Z","repository":{"id":57506291,"uuid":"132390933","full_name":"oogway/go-cache","owner":"oogway","description":"Cache Interface + Implementation","archived":false,"fork":false,"pushed_at":"2018-06-04T12:05:30.000Z","size":27,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-16T22:09:09.601Z","etag":null,"topics":["cache","golang","idempotency","redis"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oogway.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-07T01:26:50.000Z","updated_at":"2022-11-13T08:25:50.000Z","dependencies_parsed_at":"2022-08-29T20:20:15.621Z","dependency_job_id":null,"html_url":"https://github.com/oogway/go-cache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oogway%2Fgo-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oogway%2Fgo-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oogway%2Fgo-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oogway%2Fgo-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oogway","download_url":"https://codeload.github.com/oogway/go-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250227796,"owners_count":21395885,"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","golang","idempotency","redis"],"created_at":"2024-11-08T17:05:24.798Z","updated_at":"2025-04-22T11:08:14.378Z","avatar_url":"https://github.com/oogway.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-cache [![Build Status](https://travis-ci.org/oogway/go-cache.svg?branch=master)](https://travis-ci.org/oogway/go-cache)\n\nThis repository is a hard-fork of [revel-cache](https://github.com/revel/revel/tree/master/cache)\n\nMotivation to do this:\n  - light-weight cache library that doesn't download the internet.\n  - Doesn't use background go-routines for expiration.\n  - Has both in-memory, Redis and more (to be introduced) backends.\n\n## Quick Start\n\nInstallation\n\n    $ go get github.com/oogway/go-cache\n\n\n## Usage\n\n### In-memory\n\nExample:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\tcache \"github.com/oogway/go-cache\"\n)\n\nfunc main() {\n\t// Use in-memory store\n\tstore := cache.NewInMemoryCache(time.Hour)\n\n\tstore.Set(\"key\", \"value\", time.Hour)\n\n\tvar value string\n\t// Set the item\n\tstore.Get(\"key\", \u0026value)\n\tfmt.Println(\"Key:\", value)\n\n\tstore.Set(\"num\", 1, time.Hour)\n\tvar num int\n\t// Well, lets check it has set correct\n\tstore.Get(\"num\", \u0026num)\n\tfmt.Println(\"Number: \", num)\n\n\t// No longer need the item in store? DELETE IT!\n\tstore.Delete(\"key\")\n\n\t// Update value\n\t// NOTE: Replace only works iff the key exists in store\n\tstore.Replace(\"num\", 100, time.Hour)\n\tstore.Get(\"num\", \u0026num)\n\tfmt.Println(\"Replaced Number: \", num)\n\n\t// Get rid of all keys at once\n\tstore.Flush()\n}\n\n```\n\n### Redis\n\nFor Redis store just initialize store as follows\n\n\n```go\nstore := cache.NewRedisCache(cache.RedisOpts{\n    Host:       \"\",\n    Expiration: time.Hour,\n})\n```\n\nEmpty host assumes redis service on local machine (`localhost:6379`)\n\nFollowing are the options while initializing Redis store\n\n```\n    MaxIdle        int\n    MaxActive      int\n    Protocol       string\n    Host           string\n    Password       string\n    Expiration     time.Duration\n    TimeoutConnect int\n    TimeoutRead    int\n    TimeoutWrite   int\n    TimeoutIdle    int\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foogway%2Fgo-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foogway%2Fgo-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foogway%2Fgo-cache/lists"}