{"id":45120,"library":"hybrid-cache","title":"Hybrid Cache","description":"hybrid-cache v1.0.30 is a dual-layer caching library for Node.js that combines an in-memory cache (node-cache) with Redis synchronization, focusing on fastest response for basic commands. It allows adding multiple Redis servers and provides methods like set, get, setex, incrby, and flushall. Compared to alternatives like ioredis or node-cache alone, it offers a simple API for hybrid caching with optional Redis sync. Released as a stable package with monthly updates, it supports callbacks and is suitable for applications needing low-latency reads with Redis persistence.","status":"active","version":"1.0.30","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","database","redis","transaction","pipelining","performance","queue","nodejs","pubsub"],"install":[{"cmd":"npm install hybrid-cache","lang":"bash","label":"npm"},{"cmd":"yarn add hybrid-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add hybrid-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Redis client used for server communication","package":"redis","optional":false},{"reason":"In-memory cache layer","package":"node-cache","optional":false}],"imports":[{"note":"Default export; no named exports. CommonJS only.","wrong":"const { HybridCache } = require('hybrid-cache')","symbol":"HybridCache","correct":"const HybridCache = require('hybrid-cache')"},{"note":"HybridCache is a factory function, not a constructor.","wrong":"const cache = new HybridCache()","symbol":"hybridCache instance","correct":"const cache = HybridCache()"}],"quickstart":{"code":"const HybridCache = require('hybrid-cache');\nconst hybridCache = HybridCache();\n\nhybridCache.init({ waitingTime: 3, isSyncRedis: true });\n\nhybridCache.addRedisServer({ host: '127.0.0.1', port: '6379' }, (err, result) => {\n  if (err) console.error(err);\n  console.log('Redis server added:', result);\n});\n\nhybridCache.set('key1', 'value1', (err, result) => {\n  if (err) console.error(err);\n  console.log('Set result:', result);\n});\n\nhybridCache.get('key1', (err, result) => {\n  if (err) console.error(err);\n  console.log('Get result:', result);\n});","lang":"javascript","description":"Initializes hybrid-cache with a local Redis server, sets and retrieves a value."},"warnings":[{"fix":"Use const cache = HybridCache() instead of new HybridCache().","message":"HybridCache() must be called without 'new' - it's a factory function.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Read docs carefully: waitingTime default is 2 seconds, not milliseconds.","message":"The 'waitingTime' and 'retryInterval' options are in seconds but may be confused with milliseconds.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use callbacks or promisify: const { promisify } = require('util'); const setAsync = promisify(hybridCache.set.bind(hybridCache));","message":"Methods like set, get, setex are asynchronous and expect callbacks; no Promise support.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use hybridCache.get/set for unified hybrid behavior; use .Redis or .Mem only when you need to bypass the hybrid layer.","message":"Accessing hybridCache.Redis or hybridCache.Mem gives direct access to Redis and memory cache, but operations on them bypass local cache synchronization.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'ad':38 'allow':37 'alon':61 'altern':54 'api':66 'applic':89 'basic':34 'cach':2,5,12,22,25,60,69 'callback':84 'combin':17 'command':35 'compar':52 'databas':99 'dual':10 'dual-lay':9 'fastest':31 'flushal':51 'focus':29 'get':47 'hybrid':1,4,68 'hybrid-cach':3 'in-memori':19 'incrbi':49 'ioredi':56 'javascript':98 'latenc':93 'layer':11 'librari':13 'like':45,55 'low':92 'low-lat':91 'memori':21 'method':44 'month':80 'multipl':39 'need':90 'node':24,59 'node-cach':23,58 'node.js':15 'nodej':105 'offer':63 'option':71 'packag':78 'perform':103 'persist':97 'pipelin':102 'provid':43 'pubsub':106 'queue':104 'read':94 'redi':27,40,72,96,100 'releas':74 'respons':32 'server':41 'set':46 'setex':48 'simpl':65 'stabl':77 'suitabl':87 'support':83 'sync':73 'synchron':28 'transact':101 'updat':81 'v1.0.30':6","created_at":"2026-06-07T12:53:28.215941+00:00","updated_at":"2026-06-07T12:53:28.215941+00:00","problems":[{"fix":"Call HybridCache() without new.","cause":"Using 'new' keyword on factory function HybridCache.","error":"TypeError: HybridCache is not a constructor"},{"fix":"Use const HybridCache = require('hybrid-cache'); const cache = HybridCache();","cause":"Probably imported incorrectly as named export.","error":"TypeError: hybridCache.set is not a function"},{"fix":"Ensure Redis is running and accessible. Or omit isSyncRedis: true to skip Redis.","cause":"Redis server not running or incorrect host/port.","error":"Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED"},{"fix":"Call hybridCache.init() before using other methods.","cause":"Using hybridCache before calling init or addRedisServer.","error":"Error: init not called or Redis servers not added"}],"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://gitlab.com/linhlevu29/hybrid-cache#README","github":null,"docs":null,"changelog":null,"pypi":null,"npm":"hybrid-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"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}}