@@ -18,7 +18,7 @@ import { setToArray } from '../../utils/lang/sets';
1818const LOG_PREFIX = 'storage:redis-adapter: ' ;
1919
2020// If we ever decide to fully wrap every method, there's a Commander.getBuiltinCommands from ioredis.
21- const METHODS_TO_PROMISE_WRAP = [ 'set' , 'exec' , 'del' , 'get' , 'keys' , 'sadd' , 'srem' , 'sismember' , 'smembers' , 'incr' , 'rpush' , 'expire' , 'mget' , 'lrange' , 'ltrim' , 'hset' , 'hincrby' , 'popNRaw' ] ;
21+ const METHODS_TO_PROMISE_WRAP = [ 'set' , 'exec' , 'del' , 'get' , 'keys' , 'sadd' , 'srem' , 'sismember' , 'smembers' , 'incr' , 'decr' , ' rpush', 'expire' , 'mget' , 'lrange' , 'ltrim' , 'hset' , 'hincrby' , 'popNRaw' , 'hgetall' , 'llen' , 'hget '] ;
2222const METHODS_TO_PROMISE_WRAP_EXEC = [ 'pipeline' ] ;
2323
2424// Not part of the settings since it'll vary on each storage. We should be removing storage specific logic from elsewhere.
@@ -45,7 +45,7 @@ interface IRedisCommand {
4545
4646/**
4747 * Redis adapter on top of the library of choice (written with ioredis) for some extra control.
48- * Refactored to use Composition and Proxy instead of Inheritance to support both v4 and v5.
48+ * Refactored to use Composition instead of Inheritance to support both v4 and v5.
4949 */
5050export class RedisAdapter {
5151 // eslint-disable-next-line no-undef -- Index signature to allow proxying dynamic ioredis methods without TS errors
@@ -73,23 +73,10 @@ export class RedisAdapter {
7373 this . _listenToEvents ( ) ;
7474 this . _setTimeoutWrappers ( ) ;
7575 this . _setDisconnectWrapper ( ) ;
76+ }
7677
77- // Return a Proxy. This allows the adapter to act exactly like an extended class.
78- // If a method/property is accessed that we didn't explicitly wrap, it forwards it to `this.client`.
79- return new Proxy ( this , {
80- get ( target : RedisAdapter , prop : string | symbol ) {
81- // If the property exists on our wrapper (like wrapped 'get', 'set', or internal methods)
82- if ( prop in target ) {
83- return target [ prop as keyof RedisAdapter ] ;
84- }
85- // If it doesn't exist on our wrapper but exists on the real client (like 'on', 'quit')
86- if ( target . client && prop in target . client ) {
87- const val = target . client [ prop ] ;
88- return typeof val === 'function' ? val . bind ( target . client ) : val ;
89- }
90- return undefined ;
91- }
92- } ) ;
78+ on ( event : string , listener : ( ...args : any [ ] ) => void ) {
79+ return this . client . on ( event , listener ) ;
9380 }
9481
9582 _listenToEvents ( ) {
0 commit comments