@@ -15,6 +15,7 @@ def r(request):
15
15
redis .Redis , request , protocol = 3 , client_cache = cache , ** kwargs
16
16
) as client :
17
17
yield client , cache
18
+ # client.flushdb()
18
19
19
20
20
21
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
@@ -134,6 +135,17 @@ def test_cache_blacklist(self, r):
134
135
assert cache .get (("LLEN" , "mylist" )) is None
135
136
assert cache .get (("LINDEX" , "mylist" , 1 )) == b"bar"
136
137
138
+ @pytest .mark .parametrize ("r" , [{"cache" : _LocalCache ()}], indirect = True )
139
+ def test_cache_return_copy (self , r ):
140
+ r , cache = r
141
+ r .lpush ("mylist" , "foo" , "bar" , "baz" )
142
+ assert r .lrange ("mylist" , 0 , - 1 ) == [b"baz" , b"bar" , b"foo" ]
143
+ res = cache .get (("LRANGE" , "mylist" , 0 , - 1 ))
144
+ assert res == [b"baz" , b"bar" , b"foo" ]
145
+ res .append (b"new" )
146
+ check = cache .get (("LRANGE" , "mylist" , 0 , - 1 ))
147
+ assert check == [b"baz" , b"bar" , b"foo" ]
148
+
137
149
138
150
@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
139
151
@pytest .mark .onlycluster
0 commit comments