@@ -403,7 +403,6 @@ def pipeline(self):
403403 except RedisError as exc :
404404 raise RedisAdapterException ('Error executing ttl operation' ) from exc
405405
406-
407406class RedisAdapterAsync (RedisAdapterBase ): # pylint: disable=too-many-public-methods
408407 """
409408 Instance decorator for asyncio Redis clients such as StrictRedis.
@@ -609,30 +608,9 @@ async def close(self):
609608 await self ._decorated .close ()
610609 await self ._decorated .connection_pool .disconnect (inuse_connections = True )
611610
612- class RedisPipelineAdapterBase (object , metaclass = abc .ABCMeta ):
613- """
614- Template decorator for Redis Pipeline.
611+ class RedisPipelineAdapterBase (object ):
615612 """
616- @abc .abstractmethod
617- def rpush (self , key , * values ):
618- """Mimic original redis function but using user custom prefix."""
619-
620- @abc .abstractmethod
621- def incr (self , name , amount = 1 ):
622- """Mimic original redis function but using user custom prefix."""
623-
624- @abc .abstractmethod
625- def hincrby (self , name , key , amount = 1 ):
626- """Mimic original redis function but using user custom prefix."""
627-
628- @abc .abstractmethod
629- def execute (self ):
630- """Mimic original redis execute."""
631-
632-
633- class RedisPipelineAdapter (RedisPipelineAdapterBase ):
634- """
635- Instance decorator for Redis Pipeline.
613+ Base decorator for Redis Pipeline.
636614
637615 Adds an extra layer handling addition/removal of user prefix when handling
638616 keys
@@ -659,14 +637,33 @@ def hincrby(self, name, key, amount=1):
659637 """Mimic original redis function but using user custom prefix."""
660638 self ._pipe .hincrby (self ._prefix_helper .add_prefix (name ), key , amount )
661639
640+ def smembers (self , name ):
641+ """Mimic original redis function but using user custom prefix."""
642+ self ._pipe .smembers (self ._prefix_helper .add_prefix (name ))
643+
644+ class RedisPipelineAdapter (RedisPipelineAdapterBase ):
645+ """
646+ Instance decorator for Redis Pipeline.
647+
648+ Adds an extra layer handling addition/removal of user prefix when handling
649+ keys
650+ """
651+ def __init__ (self , decorated , prefix_helper ):
652+ """
653+ Store the user prefix and the redis client instance.
654+
655+ :param decorated: Instance of redis cache client to decorate.
656+ :param _prefix_helper: PrefixHelper utility
657+ """
658+ RedisPipelineAdapterBase .__init__ (self , decorated , prefix_helper )
659+
662660 def execute (self ):
663661 """Mimic original redis function but using user custom prefix."""
664662 try :
665663 return self ._pipe .execute ()
666664 except RedisError as exc :
667665 raise RedisAdapterException ('Error executing pipeline operation' ) from exc
668666
669-
670667class RedisPipelineAdapterAsync (RedisPipelineAdapterBase ):
671668 """
672669 Instance decorator for Asyncio Redis Pipeline.
@@ -681,20 +678,7 @@ def __init__(self, decorated, prefix_helper):
681678 :param decorated: Instance of redis cache client to decorate.
682679 :param _prefix_helper: PrefixHelper utility
683680 """
684- self ._prefix_helper = prefix_helper
685- self ._pipe = decorated .pipeline ()
686-
687- def rpush (self , key , * values ):
688- """Mimic original redis function but using user custom prefix."""
689- self ._pipe .rpush (self ._prefix_helper .add_prefix (key ), * values )
690-
691- def incr (self , name , amount = 1 ):
692- """Mimic original redis function but using user custom prefix."""
693- self ._pipe .incr (self ._prefix_helper .add_prefix (name ), amount )
694-
695- def hincrby (self , name , key , amount = 1 ):
696- """Mimic original redis function but using user custom prefix."""
697- self ._pipe .hincrby (self ._prefix_helper .add_prefix (name ), key , amount )
681+ RedisPipelineAdapterBase .__init__ (self , decorated , prefix_helper )
698682
699683 async def execute (self ):
700684 """Mimic original redis function but using user custom prefix."""
0 commit comments