{"id":14954621,"url":"https://github.com/meteor/miniredis","last_synced_at":"2025-06-19T10:41:53.184Z","repository":{"id":18159423,"uuid":"21257481","full_name":"meteor/miniredis","owner":"meteor","description":"javascript in-memory implementation of Redis API with observe changes interface and reactivity","archived":false,"fork":false,"pushed_at":"2014-10-29T20:08:47.000Z","size":364,"stargazers_count":67,"open_issues_count":0,"forks_count":1,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-06-19T01:04:01.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://atmospherejs.com/package/miniredis","language":"JavaScript","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/meteor.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":"2014-06-26T22:53:50.000Z","updated_at":"2023-09-12T07:32:43.000Z","dependencies_parsed_at":"2022-08-28T05:21:28.703Z","dependency_job_id":null,"html_url":"https://github.com/meteor/miniredis","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/meteor/miniredis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fminiredis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fminiredis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fminiredis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fminiredis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meteor","download_url":"https://codeload.github.com/meteor/miniredis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteor%2Fminiredis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260735549,"owners_count":23054704,"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":[],"created_at":"2024-09-24T13:04:32.089Z","updated_at":"2025-06-19T10:41:48.163Z","avatar_url":"https://github.com/meteor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Miniredis\n\nThis is an all-javascript in-memory implementation of the [Redis](https://redis.io) API,\nadapted for Meteor.\n\n```javascript\nvar redis = new Miniredis.RedisStore;\nredis.set(\"key-1-1\", \"foo\");\nredis.set(\"key-1-2\", \"bar\");\n```\n\nYou can install it by running:\n\n    meteor add slava:miniredis\n\n## Reactivity\n\nThis implementation supports\n[Deps.js](https://github.com/meteor/meteor/blob/devel/packages/deps)\nreactivity with fine-grained reactivity: if a command was run in a\nDeps.autorun computation, then the minimal set of dependencies will be tracked.\n\n```javascript\nvar redis = new Miniredis.RedisStore;\nredis.set(\"key-1-1\", \"foo\");\n\nDeps.autorun(function () {\n  console.log(_.pluck(redis.matching(\"key-1-*\").fetch(), \"value\"));\n});\n// prints [\"foo\"]\n\nredis.set(\"key-2-1\", \"baz\");\n// doesn't print anything\n\nredis.set(\"key-1-2\", \"bar\");\n// prints [\"foo\", \"bar\"]\n\nredis.set(\"key-1-1\", \"foo1\");\n// prints [\"foo1\", \"bar\"]\n```\n\n## Observe API\n\nSimilar to Minimongo's Cursor's, Miniredis Cursors (as returned by\n`redis.matching(\"*-pattern-*\")` calls) can be observed with `added`, `changed`\nand `removed` callbacks.\n\n```javascript\nredis.matching(\"key-2-*\").observe({\n  added: function (item) { /* item: { _id, value } */ },\n  changed: function (item, oldItem) { /* item: { _id, value} */ },\n  removed: function (item) { /* item: { _id, value } */ }\n});\n```\n\nYou can also have an ordered observe by passing `addedAt`, `changedAt`,\n`removedAt` callbacks. The current order is the lexicographical order of keys.\n\n```javascript\nredis.matching(\"key-2-*\").observe({\n  addedAt: function (item, atIndex, before) { /* item: { _id, value } */ },\n  changedAt: function (item, oldItem, atIndex) { /* item: { _id, value} */ },\n  removedAt: function (item, atIndex) { /* item: { _id, value } */ }\n});\n```\n\n`observeChanges` is also implemented but it is not very different from the\n`observe` version as of yet.\n\nYou can pause/resume observers with the same API as of Minimongo:\n\n```javascript\n// Pause observers\nredis.pauseObservers();\n// Make a lot of changes\n_.each(removedValues, function (value, key) {\n  redis.del(key);\n});\n_.each(newValues, function (value, key) {\n  redis.set(key, value);\n});\n// Resume\nredis.resumeObservers();\n```\n\n## Blaze compatibility\n\nMiniredis's cursors can be observed by [Blaze](http://meteor.github.io/blaze):\n\n```html\n\u003ctemplate name=\"orderedList\"\u003e\n  {{#each listItems}}\n    \u003cdiv\u003e{{_id}} - {{value}}\u003c/div\u003e\n  {{/each}}\n\u003c/template\u003e\n```\n\n```javascript\nTemplate.orderedList.listItems = function () {\n  return redis.matching(\"key-2-*\");\n};\n```\n\n## Known Issue\n\n- on Meteor 0.8.2 returning a miniredis cursor from a template helper Blaze will\n  not observe it properly. It is fixed on the `devel` branch and will be\n  released in next Meteor version. To workaround it, return a fetched array from\n  cursor.\n\n## Redis API compatibility\n\nTo support [Meteor](https://www.meteor.com)'s latency compensation,\nthis implementation tries to mimic the behavior of the Redis server.\n\nRight now these Redis commands are implemented and available:\n\n### On Strings\n\n- set\n- get\n- del\n- exists\n- keys\n- randomkey\n- rename\n- renamenx\n- type\n- append\n- decr\n- decrby\n- getrange\n- getset\n- incr\n- incrby\n- incrbyfloat\n- mget\n- mset\n- msetnx\n- setx\n- setnx\n- setrange\n- strlen\n\n### On Hashes\n\n- hset\n- hsetnx\n- hget\n- hkeys\n- hvals\n- hgetall\n- hincrby\n- hincrbyfloat\n- hdel\n- hmset\n- hmget\n- hlen\n- hexists\n\n### On Lists\n\n- lpush\n- rpush\n- lpop\n- rpop\n- lindex\n- linsert\n- lrange\n- lset\n- ltrim\n- llen\n- lpushx\n- rpushx\n\n## License\n\nMIT (c) Meteor Development Group\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeteor%2Fminiredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeteor%2Fminiredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeteor%2Fminiredis/lists"}