{"id":46117,"library":"redis-json","title":"redis-json","description":"A library that stores JSON objects in Redis hashes without losing type information, using a flatten/unflatten approach. Current stable version is 6.0.3, with active development. It handles nested objects, arrays, and custom types via stringifier/parser options. Compared to directly storing JSON strings, it allows partial updates and field-level retrieval. Requires ioredis as a peer dependency. Ships TypeScript definitions.","status":"active","version":"6.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/AkashBabu/redis-json","tags":["javascript","redis","json","store","retrieve","save","insert","hashset","typescript"],"install":[{"cmd":"npm install redis-json","lang":"bash","label":"npm"},{"cmd":"yarn add redis-json","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-json","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Redis client used for all operations","package":"ioredis","optional":false}],"imports":[{"note":"Default export is the class; named import fails in both ESM and CJS.","wrong":"import { JSONCache } from 'redis-json'","symbol":"JSONCache","correct":"import JSONCache from 'redis-json'"},{"note":"CJS require returns the default export directly.","wrong":"const { JSONCache } = require('redis-json')","symbol":"JSONCache","correct":"const JSONCache = require('redis-json')"}],"quickstart":{"code":"import Redis from 'ioredis';\nimport JSONCache from 'redis-json';\n\nconst redis = new Redis();\nconst cache = new JSONCache(redis, { prefix: 'jc:' });\n\nasync function run() {\n  const obj = { name: 'test', count: 42, tags: ['a', 'b'] };\n  await cache.set('123', obj);\n  console.log(await cache.get('123'));\n  await cache.clearAll();\n}\nrun();","lang":"typescript","description":"Shows basic instantiation with ioredis, set/get operations, and clearing all keys."},"warnings":[{"fix":"Review array handling logic in your app; previously arrays were merged.","message":"In v6.0.0, the behavior for array replacement changed: arrays cached in Redis are now replaced entirely when set is called with a new array.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Avoid calling `clearAll()` frequently; consider alternative TTL-based cleanup.","message":"The `clearAll()` method uses `scan` under the hood, which may cause high CPU usage on large datasets.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Do not wrap `get` or `clearAll` in a multi/exec block; use them separately.","message":"Transactions are only supported for `set`, `rewrite`, `del`, and `incr` methods. Using `get` or `clearAll` inside a transaction will throw an error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace `clearAll()` with a custom cleanup using Redis `scan` and `del`, or set TTL on keys.","message":"The `clearAll` method is deprecated since v6.0.0 in favor of using Redis TTL or explicit key deletion.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Update custom stringifiers/parsers to return appropriate types (string for stringifier, value for parser).","message":"Breaking change in v6: the `stringifier` and `parser` options now require functions that return string/object, not just serialize/deserialize.","severity":"breaking","affected_versions":">=6.0.0"}],"env_vars":null,"search_vec":"'6.0.3':25 'activ':27 'allow':47 'approach':20 'array':33 'compar':40 'current':21 'custom':35 'definit':63 'depend':60 'develop':28 'direct':42 'field':52 'field-level':51 'flatten/unflatten':19 'handl':30 'hash':12 'hashset':71 'inform':16 'insert':70 'ioredi':56 'javascript':64 'json':3,8,44,66 'level':53 'librari':5 'lose':14 'nest':31 'object':9,32 'option':39 'partial':48 'peer':59 'redi':2,11,65 'redis-json':1 'requir':55 'retriev':54,68 'save':69 'ship':61 'stabl':22 'store':7,43,67 'string':45 'stringifier/parser':38 'type':15,36 'typescript':62,72 'updat':49 'use':17 'version':23 'via':37 'without':13","created_at":"2026-06-07T12:58:22.880477+00:00","updated_at":"2026-06-07T12:58:22.880477+00:00","problems":[{"fix":"Use an ioredis client instead of node-redis or other clients.","cause":"The redis client instance is not ioredis; the library assumes ioredis API.","error":"TypeError: redis.hmset is not a function"},{"fix":"Use get outside transaction block.","cause":"Calling get inside a multi() transaction.","error":"Error: get() does not support transactions"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/AkashBabu/redis-json#readme","github":"https://github.com/AkashBabu/redis-json","docs":null,"changelog":null,"pypi":null,"npm":"redis-json","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}