@@ -15,6 +15,7 @@ def r(request):
1515 redis .Redis , request , protocol = 3 , client_cache = cache , ** kwargs
1616 ) as client :
1717 yield client , cache
18+ # client.flushdb()
1819
1920
2021@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
@@ -134,6 +135,17 @@ def test_cache_blacklist(self, r):
134135 assert cache .get (("LLEN" , "mylist" )) is None
135136 assert cache .get (("LINDEX" , "mylist" , 1 )) == b"bar"
136137
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+
137149
138150@pytest .mark .skipif (HIREDIS_AVAILABLE , reason = "PythonParser only" )
139151@pytest .mark .onlycluster
0 commit comments