Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Key
✓ const { Key } = require('redis-types')
✗ import { Key } from 'redis-types'
Package uses CommonJS, not ESM.
RedisHash
✓ const { RedisHash } = require('redis-types')
✗ const RedisHash = require('redis-types').Hash
Exported name is 'RedisHash', not 'Hash'.
RedisList
✓ const { RedisList } = require('redis-types')
✗ const RedisList = require('redis-types').List
Exported name is 'RedisList', not 'List'.
RedisSet
✓ const { RedisSet } = require('redis-types')
✗ const RedisSet = require('redis-types').Set
Exported name is 'RedisSet', not 'Set'.
RedisSortedSet
✓ const { RedisSortedSet } = require('redis-types')
✗ const RedisSortedSet = require('redis-types').SortedSet
Exported name is 'RedisSortedSet', not 'SortedSet'.
String
✓ const { String } = require('redis-types')
✗ const RedisString = require('redis-types').RedisString
Exported as 'String', but often mistaken as 'RedisString'.
Demonstrates creating Key, Hash, and List objects with a redis client, performing basic operations.
const redis = require('redis');
const { Key, String, RedisHash, RedisList, RedisSet, RedisSortedSet } = require('redis-types');
const client = redis.createClient();
const myKey = new Key('mykey', client);
myKey.set('value', (err, res) => {
console.log('SET result:', res);
});
const myHash = new RedisHash('myhash', client);
myHash.hset('field1', 'val1', (err, res) => {
myHash.hget('field1', (err, val) => {
console.log('HGET:', val);
});
});
const myList = new RedisList('mylist', client);
myList.rpush('a', 'b', 'c', (err) => {
myList.lrange(0, -1, (err, items) => {
console.log('LRANGE:', items);
});
});
Errors
Common errors & fixes
TypeError: RedisHash is not a constructor
Importing as require('redis-types').Hash instead of .RedisHash
fixUse const { RedisHash } = require('redis-types'); Module not found: Can't resolve 'redis-types'
Package not installed or typo in require path.
fixRun 'npm install redis-types' and ensure correct import.
Audit
Dependencies
redisrequiredredis-types wraps the 'redis' module; it must be installed separately