{"id":46180,"library":"redis-typed-keys","title":"redis-typed-keys","description":"redis-typed-keys is a TypeScript library (v0.2.1, pre-1.0, irregular releases) that provides a type-safe wrapper around Redis commands, enforcing key naming conventions (prefixes, separators) and typed data structures (hashes, sets, sorted sets). Unlike raw redis or ioredis, it prevents runtime mistakes by ensuring keys follow defined patterns and values are serialized/deserialized correctly. It ships its own types but depends on a Redis client (e.g., ioredis).","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/aantthony/redis-typed-keys","tags":["javascript","redis","typescript"],"install":[{"cmd":"npm install redis-typed-keys","lang":"bash","label":"npm"},{"cmd":"yarn add redis-typed-keys","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-typed-keys","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for actual Redis connection; the library only wraps commands.","package":"ioredis","optional":false}],"imports":[{"note":"ESM-only; CJS require will not work.","wrong":"const RedisTypedKeys = require('redis-typed-keys')","symbol":"RedisTypedKeys","correct":"import { RedisTypedKeys } from 'redis-typed-keys'"},{"note":"Default export is a factory; named import is correct.","wrong":"const { createClient } = require('redis-typed-keys')","symbol":"createClient","correct":"import { createClient } from 'redis-typed-keys'"},{"note":"TypeScript only; use import type for runtime-free types.","symbol":"KeySchema","correct":"import type { KeySchema } from 'redis-typed-keys'"}],"quickstart":{"code":"import { RedisTypedKeys } from 'redis-typed-keys';\nimport Redis from 'ioredis';\n\nconst redisClient = new Redis({ host: process.env.REDIS_HOST || 'localhost' });\nconst client = new RedisTypedKeys(redisClient, {\n  prefix: 'app:',\n  schemas: {\n    user: {\n      key: (id: string) => `user:${id}`,\n      fields: ['name', 'email'] as const,\n    },\n  },\n});\n\nasync function demo() {\n  const userId = '123';\n  await client.hSet('user', userId, { name: 'Alice', email: 'alice@example.com' });\n  const user = await client.hGetAll('user', userId);\n  console.log(user);\n}\n\ndemo().catch(console.error);","lang":"typescript","description":"Shows typed Redis hash operations: set and get a user record using schema-defined key prefixes and field types."},"warnings":[{"fix":"Update schema initialization: replace `keys` with `schemas` and adjust structure.","message":"Key schema configuration changed between 0.1.x and 0.2.x: now uses `schemas` object instead of `keys`.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use `client.client` instead of `client.getClient()`.","message":"The `.getClient()` method is deprecated in favor of direct access via `.client`.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Ensure all used key names are added to the schema before operations.","message":"All keys must be defined in schema; unknown keys throw runtime errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Enable `strict` in tsconfig.json to enforce schema types.","message":"TypeScript strict mode required for full type safety; loose mode may allow untyped operations.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'-1.0':15 'around':25 'client':72 'command':27 'convent':31 'correct':61 'data':36 'defin':55 'depend':68 'e.g':73 'enforc':28 'ensur':52 'follow':54 'hash':38 'ioredi':46,74 'irregular':16 'javascript':75 'key':4,8,29,53 'librari':12 'mistak':50 'name':30 'pattern':56 'pre':14 'prefix':32 'prevent':48 'provid':19 'raw':43 'redi':2,6,26,44,71,76 'redis-typed-key':1,5 'releas':17 'runtim':49 'safe':23 'separ':33 'serialized/deserialized':60 'set':39,41 'ship':63 'sort':40 'structur':37 'type':3,7,22,35,66 'type-saf':21 'typescript':11,77 'unlik':42 'v0.2.1':13 'valu':58 'wrapper':24","created_at":"2026-06-07T12:58:39.883224+00:00","updated_at":"2026-06-07T12:58:39.883224+00:00","problems":[{"fix":"Add the missing schema definition or correct the key name.","cause":"Key schema name provided to operation does not exist in schemas map.","error":"TypeError: Cannot read properties of undefined (reading 'key')"},{"fix":"Use client.client directly (the underlying Redis connection).","cause":"Using deprecated getClient() method removed in 0.2.0.","error":"TypeError: client.getClient is not a function"},{"fix":"Check that Redis is running locally or set REDIS_HOST environment variable.","cause":"ioredis cannot connect; Redis server not running or wrong host/port.","error":"Error: Redis connection refused (ECONNREFUSED)"}],"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/aantthony/redis-typed-keys#readme","github":"https://github.com/aantthony/redis-typed-keys","docs":null,"changelog":null,"pypi":null,"npm":"redis-typed-keys","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}}