@@ -41,7 +41,7 @@ def r(request):
41
41
42
42
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
43
43
@pytest .mark .onlynoncluster
44
- @skip_if_resp_version (2 )
44
+ # @skip_if_resp_version(2)
45
45
@skip_if_server_version_lt ("7.4.0" )
46
46
class TestCache :
47
47
@pytest .mark .parametrize (
@@ -109,8 +109,8 @@ def test_get_from_given_cache(self, r, r2):
109
109
@pytest .mark .onlynoncluster
110
110
def test_get_from_default_cache (self , r , r2 ):
111
111
cache = r .get_cache ()
112
- assert isinstance (cache .get_eviction_policy () , LRUPolicy )
113
- assert cache .get_config () .get_max_size () == 128
112
+ assert isinstance (cache .eviction_policy , LRUPolicy )
113
+ assert cache .config .get_max_size () == 128
114
114
115
115
# add key to redis
116
116
r .set ("foo" , "bar" )
@@ -161,7 +161,7 @@ def test_cache_clears_on_disconnect(self, r, cache):
161
161
# Force disconnection
162
162
r .connection_pool .get_connection ("_" ).disconnect ()
163
163
# Make sure cache is empty
164
- assert cache .get_size () == 0
164
+ assert cache .size == 0
165
165
166
166
@pytest .mark .parametrize (
167
167
"r" ,
@@ -207,7 +207,7 @@ def test_cache_lru_eviction(self, r, cache):
207
207
assert r .get ("foo4" ) == b"bar4"
208
208
# the first key is not in the local cache anymore
209
209
assert cache .get (CacheKey (command = "GET" , redis_keys = ("foo" ,))) is None
210
- assert cache .get_size () == 3
210
+ assert cache .size == 3
211
211
212
212
@pytest .mark .parametrize (
213
213
"r" ,
@@ -321,7 +321,7 @@ def test_cache_flushed_on_server_flush(self, r):
321
321
# Flush server and trying to access cached entry
322
322
assert r .flushall ()
323
323
assert r .get ("foo" ) is None
324
- assert cache .get_size () == 0
324
+ assert cache .size == 0
325
325
326
326
327
327
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
@@ -383,8 +383,8 @@ def test_get_from_cache(self, r):
383
383
)
384
384
def test_get_from_custom_cache (self , r , r2 ):
385
385
cache = r .nodes_manager .get_node_from_slot (12000 ).redis_connection .get_cache ()
386
- assert isinstance (cache .get_eviction_policy () , LRUPolicy )
387
- assert cache .get_config () .get_max_size () == 128
386
+ assert isinstance (cache .eviction_policy , LRUPolicy )
387
+ assert cache .config .get_max_size () == 128
388
388
389
389
# add key to redis
390
390
assert r .set ("foo" , "bar" )
@@ -431,7 +431,7 @@ def test_cache_clears_on_disconnect(self, r, r2):
431
431
12000
432
432
).redis_connection .connection_pool .get_connection ("_" ).disconnect ()
433
433
# Make sure cache is empty
434
- assert cache .get_size () == 0
434
+ assert cache .size == 0
435
435
436
436
@pytest .mark .parametrize (
437
437
"r" ,
@@ -564,7 +564,7 @@ def test_cache_flushed_on_server_flush(self, r, cache):
564
564
# Flush server and trying to access cached entry
565
565
assert r .flushall ()
566
566
assert r .get ("foo{slot}" ) is None
567
- assert cache .get_size () == 0
567
+ assert cache .size == 0
568
568
569
569
570
570
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
@@ -623,7 +623,7 @@ def test_get_from_cache(self, master):
623
623
)
624
624
def test_get_from_default_cache (self , r , r2 ):
625
625
cache = r .get_cache ()
626
- assert isinstance (cache .get_eviction_policy () , LRUPolicy )
626
+ assert isinstance (cache .eviction_policy , LRUPolicy )
627
627
628
628
# add key to redis
629
629
r .set ("foo" , "bar" )
@@ -669,7 +669,7 @@ def test_cache_clears_on_disconnect(self, master, cache):
669
669
# Force disconnection
670
670
master .connection_pool .get_connection ("_" ).disconnect ()
671
671
# Make sure cache_data is empty
672
- assert cache .get_size () == 0
672
+ assert cache .size == 0
673
673
674
674
675
675
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
@@ -734,7 +734,7 @@ def test_get_from_cache(self, r, r2, cache):
734
734
)
735
735
def test_get_from_custom_cache (self , r , r2 ):
736
736
cache = r .get_cache ()
737
- assert isinstance (cache .get_eviction_policy () , LRUPolicy )
737
+ assert isinstance (cache .eviction_policy , LRUPolicy )
738
738
739
739
# add key to redis
740
740
r .set ("foo" , "bar" )
@@ -798,15 +798,15 @@ def test_cache_invalidate_all_related_responses(self, r):
798
798
class TestUnitDefaultCache :
799
799
def test_get_eviction_policy (self ):
800
800
cache = DefaultCache (CacheConfig (max_size = 5 ))
801
- assert isinstance (cache .get_eviction_policy () , LRUPolicy )
801
+ assert isinstance (cache .eviction_policy , LRUPolicy )
802
802
803
803
def test_get_max_size (self ):
804
804
cache = DefaultCache (CacheConfig (max_size = 5 ))
805
- assert cache .get_config () .get_max_size () == 5
805
+ assert cache .config .get_max_size () == 5
806
806
807
807
def test_get_size (self ):
808
808
cache = DefaultCache (CacheConfig (max_size = 5 ))
809
- assert cache .get_size () == 0
809
+ assert cache .size == 0
810
810
811
811
@pytest .mark .parametrize (
812
812
"cache_key" , [{"command" : "GET" , "redis_keys" : ("bar" ,)}], indirect = True
@@ -988,7 +988,7 @@ def test_delete_by_cache_keys_removes_associated_entries(self, mock_connection):
988
988
True ,
989
989
False ,
990
990
]
991
- assert len (cache .get_collection () ) == 1
991
+ assert len (cache .collection ) == 1
992
992
assert cache .get (cache_key3 ).cache_value == b"bar2"
993
993
994
994
def test_delete_by_redis_keys_removes_associated_entries (self , mock_connection ):
@@ -1034,7 +1034,7 @@ def test_delete_by_redis_keys_removes_associated_entries(self, mock_connection):
1034
1034
)
1035
1035
1036
1036
assert cache .delete_by_redis_keys ([b"foo" , b"foo1" ]) == [True , True , True ]
1037
- assert len (cache .get_collection () ) == 1
1037
+ assert len (cache .collection ) == 1
1038
1038
assert cache .get (cache_key4 ).cache_value == b"bar3"
1039
1039
1040
1040
def test_flush (self , mock_connection ):
@@ -1071,7 +1071,7 @@ def test_flush(self, mock_connection):
1071
1071
)
1072
1072
1073
1073
assert cache .flush () == 3
1074
- assert len (cache .get_collection () ) == 0
1074
+ assert len (cache .collection ) == 0
1075
1075
1076
1076
1077
1077
class TestUnitLRUPolicy :
@@ -1083,7 +1083,7 @@ def test_evict_next(self, mock_connection):
1083
1083
cache = DefaultCache (
1084
1084
CacheConfig (max_size = 5 , eviction_policy = EvictionPolicy .LRU )
1085
1085
)
1086
- policy = cache .get_eviction_policy ()
1086
+ policy = cache .eviction_policy
1087
1087
1088
1088
cache_key1 = CacheKey (command = "GET" , redis_keys = ("foo" ,))
1089
1089
cache_key2 = CacheKey (command = "GET" , redis_keys = ("bar" ,))
@@ -1112,7 +1112,7 @@ def test_evict_many(self, mock_connection):
1112
1112
cache = DefaultCache (
1113
1113
CacheConfig (max_size = 5 , eviction_policy = EvictionPolicy .LRU )
1114
1114
)
1115
- policy = cache .get_eviction_policy ()
1115
+ policy = cache .eviction_policy
1116
1116
cache_key1 = CacheKey (command = "GET" , redis_keys = ("foo" ,))
1117
1117
cache_key2 = CacheKey (command = "GET" , redis_keys = ("bar" ,))
1118
1118
cache_key3 = CacheKey (command = "GET" , redis_keys = ("baz" ,))
@@ -1153,7 +1153,7 @@ def test_touch(self, mock_connection):
1153
1153
cache = DefaultCache (
1154
1154
CacheConfig (max_size = 5 , eviction_policy = EvictionPolicy .LRU )
1155
1155
)
1156
- policy = cache .get_eviction_policy ()
1156
+ policy = cache .eviction_policy
1157
1157
1158
1158
cache_key1 = CacheKey (command = "GET" , redis_keys = ("foo" ,))
1159
1159
cache_key2 = CacheKey (command = "GET" , redis_keys = ("bar" ,))
@@ -1175,7 +1175,7 @@ def test_touch(self, mock_connection):
1175
1175
)
1176
1176
)
1177
1177
1178
- assert cache .get_collection () .popitem (last = True )[0 ] == cache_key2
1178
+ assert cache .collection .popitem (last = True )[0 ] == cache_key2
1179
1179
cache .set (
1180
1180
CacheEntry (
1181
1181
cache_key = cache_key2 ,
@@ -1186,7 +1186,7 @@ def test_touch(self, mock_connection):
1186
1186
)
1187
1187
1188
1188
policy .touch (cache_key1 )
1189
- assert cache .get_collection () .popitem (last = True )[0 ] == cache_key1
1189
+ assert cache .collection .popitem (last = True )[0 ] == cache_key1
1190
1190
1191
1191
def test_throws_error_on_invalid_cache (self ):
1192
1192
policy = LRUPolicy ()
0 commit comments