{"id":18750727,"url":"https://github.com/cafebazaar/mnemosyne","last_synced_at":"2025-04-12T23:32:25.994Z","repository":{"id":141888510,"uuid":"226483579","full_name":"cafebazaar/mnemosyne","owner":"cafebazaar","description":"Multilayer Cache Manager supporting multiple In-momery \u0026 Redis configurations","archived":false,"fork":false,"pushed_at":"2025-03-20T18:59:32.000Z","size":187,"stargazers_count":17,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T18:06:42.252Z","etag":null,"topics":["bigcache","cache","cafebazaar","golang","multi-layer-cache","redis","redis-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/cafebazaar.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-07T09:04:42.000Z","updated_at":"2025-03-03T10:47:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"90eacada-603c-48a8-b24f-845bec05bc68","html_url":"https://github.com/cafebazaar/mnemosyne","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2Fmnemosyne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2Fmnemosyne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2Fmnemosyne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2Fmnemosyne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cafebazaar","download_url":"https://codeload.github.com/cafebazaar/mnemosyne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647258,"owners_count":21139081,"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":["bigcache","cache","cafebazaar","golang","multi-layer-cache","redis","redis-cache"],"created_at":"2024-11-07T17:12:55.426Z","updated_at":"2025-04-12T23:32:25.988Z","avatar_url":"https://github.com/cafebazaar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mnemosyne\n\n![Mnemosyne](.github/logo.png?raw=true)\n\nMnemosyne  (/nɪˈmɒzɪniː, nɪˈmɒsɪniː/; Greek: Μνημοσύνη, pronounced [mnɛːmosýːnɛː]) is a multilayer cache which can be configured to use various configurations of [Redis](https://redis.io/) and/or [BigCache](https://github.com/allegro/bigcache) (an in-memory caching package) with minimum configuration out of the box.\n\n## Getting Started\n\n### Installing\n\n```console\ngo get -u github.com/cafebazaar/mnemosyne\n```\n\n\n### Initializing a Manager and Selecting a Cache Instance\n\n```go\nmnemosyneManager := mnemosyne.NewMnemosyne(config, nil, nil)\ncacheInstance := mnemosyneManager.select(\"result-cache\")\n```\n\n### Working with a cacheInstance\n```go\n  cacheInstance.Set(context, key, value)\n  var myCachedData myType\n  err := cacheInstance.Get(context, key, \u0026myCachedData)\n  // cache miss is also an Error\n```\n\n## Configuration\n\nMnemosyne uses Viper as it's config engine. Template of each cache instance includes the list of the layers' names (in order of precedence) followed by configuration for each layer.\nhere's an example: \n```yaml\ncache:\n  my-result-cache: # arbitary name for the cache instance\n    soft-ttl: 2h \n    layers:   # Arbitary names for each cache layer\n      - result-memory\n      - result-guardian\n    result-memory:\n      type: memory\n      max-memory: 512\n      ttl: 2h\n      amnesia: 10\n      compression: true\n    result-guardian:\n      type: guardian\n      address: \"localhost:6379\"\n      slaves:\n        - \"localhost:6380\"\n        - \"localhost:6381\"\n      db: 2\n      ttl: 24h\n      amnesia: 0\n      compression: true\n  my-user-cache:\n    soft-ttl: 2h\n    layers:\n      - user-memory\n      - user-redis\n    user-memory:\n      type: memory\n      max-memory: 512\n      ttl: 2h\n      amnesia: 0\n      compression: true\n    user-redis:\n      type: redis\n      address: \"localhost:6379\"\n      db: 4\n      ttl: 24h\n      amnesia: 0\n      compression: true\n```\n\n`soft-ttl` is an instance-wide TTL which when expired will **NOT** remove the data from the instance, but warns that the data is old\n\nEach cache layer can be of types `redis`, `guardian`, `memory` or `tiny`. `redis` is used for a single node Redis server, `guardian` is used for a master-slave Redis cluster configuration, `memory` uses the BigCache library to provide an efficient and fast in-memory cache, `tiny` uses the native sync.map data structure to store smaller cache values in memory (used for low-write caches).\nNote: all of the cache types are sync-safe, meaning they can be safely used from simultaneously running goroutines.\n\n#### Common layer configs:\n\n`amnesia` is a stochastic fall-through mechanism which allows for a higher layer to be updated from a lower layer by the way of an artificial cache-miss, \na 0 amnesia means that the layers will never miss a data that they actually have, a 10 amnesia means when a key is present in the cache, 90% of the time it is returned but 10% of the time it is ignored and is treated as a cache-miss. a 100 amnesia effectively turns the layer off. (Default: 0)\n\n`compression` is whther the data is compressed before being put into the cache memory. Currently only Zlib compression is supported. (Default: false)\n\n`ttl` is the hard Time To Live for the data in this particular layer, after which the data is expired and is expected to be removed.\n\n#### Type-spesific layer configs:\n\n`db` [`redis` - `guardian`] is the Redis DB number to be used. (Default:0)\n\n`idle-timeout` [`redis` - `guardian`] is the timeout for idle connections to the Redis Server (see Redis documentation) (Default:0 - no timeout)\n\n`read-timeout` [`redis` - `guardian`] is the timeout for read connections to the Redis Server (see Redis documentation) (Default:0 - 3 seconds)\n\n`write-timeout` [`redis` - `guardian`] is the timeout for write connections to the Redis Server (see Redis documentation) (Default:0 - 3 seconds)\n\n`address` [`redis` - `guardian`] is the Redis Server's Address (the master's address in case of a cluster)\n\n`slaves` [`guardian`] is a **list** of Redis servers addresses pertaining to the slave nodes.\n\n`max-memory` [`memory`] is the maximum amount of system memory which can be used by this particular layer.\n\n## Documentation\n\nDocuments are available at [https://godoc.org/github.com/cafebazaar/mnemosyne](https://godoc.org/github.com/cafebazaar/mnemosyne)\n\n## Built With\n\n* [Redis Go clinet](https://github.com/go-redis/redis) - Redis Client for Golang\n* [BigCache](https://github.com/allegro/bigcache) - An In-Memory cache library\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/cafebazaar/mnemosyne/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/cafebazaar/mnemosyne/tags). \n\n## Roadmap\n    - Improve documentation\n    - Add tests\n\n## Authors\n\n* **Ramtin Rostami** - *Initial work* - [rrostami](https://github.com/rrostami)\n* **Pedram Teymoori** - *Initial work* - [pedramteymoori](https://github.com/pedramteymoori)\n* **Parsa abdollahi** - *Initial work* - []()\n\nSee also the list of [contributors](https://github.com/cafebazaar/Mnemosyne/graphs/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* [Sepehr Nematollahi](https://www.behance.net/sseeppeehhrr) Mnemosyne typography designer\n\nMade with \u003cspan class=\"heart\"\u003e❤\u003c/span\u003e in Cafebazaar Search Team\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafebazaar%2Fmnemosyne","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafebazaar%2Fmnemosyne","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafebazaar%2Fmnemosyne/lists"}