@@ -797,3 +797,38 @@ def test_clear(self, cache: RedisCache):
797
797
cache .clear ()
798
798
value_from_cache_after_clear = cache .get ("foo" )
799
799
assert value_from_cache_after_clear is None
800
+
801
+ def test_hset (self , cache : RedisCache ):
802
+ cache .hset ("foo_hash1" , "foo1" , "bar1" )
803
+ cache .hset ("foo_hash1" , "foo2" , "bar2" )
804
+ assert cache .hlen ("foo_hash1" ) == 2
805
+
806
+ def test_hdel (self , cache : RedisCache ):
807
+ cache .hset ("foo_hash2" , "foo1" , "bar1" )
808
+ cache .hset ("foo_hash2" , "foo2" , "bar2" )
809
+ assert cache .hlen ("foo_hash2" ) == 2
810
+ cache .hdel ("foo_hash2" , "foo1" )
811
+ assert cache .hlen ("foo_hash2" ) == 1
812
+ assert not cache .hexists ("foo_hash2" , "foo1" )
813
+ assert cache .hexists ("foo_hash2" , "foo2" )
814
+
815
+ def test_hlen (self , cache : RedisCache ):
816
+ assert cache .hlen ("foo_hash3" ) == 0
817
+ cache .hset ("foo_hash3" , "foo1" , "bar1" )
818
+ assert cache .hlen ("foo_hash3" ) == 1
819
+ cache .hset ("foo_hash3" , "foo2" , "bar2" )
820
+ assert cache .hlen ("foo_hash3" ) == 2
821
+
822
+ def test_hkeys (self , cache : RedisCache ):
823
+ cache .hset ("foo_hash4" , "foo1" , "bar1" )
824
+ cache .hset ("foo_hash4" , "foo2" , "bar2" )
825
+ cache .hset ("foo_hash4" , "foo3" , "bar3" )
826
+ keys = cache .hkeys ("foo_hash4" )
827
+ assert len (keys ) == 3
828
+ for i in range (len (keys )):
829
+ assert keys [i ] == f"foo{ i + 1 } "
830
+
831
+ def test_hexists (self , cache : RedisCache ):
832
+ cache .hset ("foo_hash5" , "foo1" , "bar1" )
833
+ assert cache .hexists ("foo_hash5" , "foo1" )
834
+ assert not cache .hexists ("foo_hash5" , "foo" )
0 commit comments