Skip to content

Commit 726803a

Browse files
committed
Fixed characters per line restriction
1 parent 852c36f commit 726803a

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

redis/asyncio/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
)
2828

2929
from cachetools import Cache
30-
3130
from redis._parsers.helpers import (
3231
_RedisCallbacks,
3332
_RedisCallbacksRESP2,

redis/connection.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from abc import abstractmethod
99
from itertools import chain
1010
from queue import Empty, Full, LifoQueue
11-
from time import time, sleep
11+
from time import time
1212
from typing import Any, Callable, List, Optional, Type, Union
1313
from urllib.parse import parse_qs, unquote, urlparse
1414

1515
from apscheduler.schedulers.background import BackgroundScheduler
16-
from cachetools import TTLCache, Cache, LRUCache
16+
from cachetools import Cache, LRUCache
1717
from cachetools.keys import hashkey
1818
from redis.cache import CacheConfiguration, CacheFactory
1919

@@ -773,13 +773,15 @@ def check_health(self):
773773
self._conn.check_health()
774774

775775
def send_packed_command(self, command, check_health=True):
776-
# TODO: Investigate if it's possible to unpack command or extract keys from packed command
776+
# TODO: Investigate if it's possible to unpack command
777+
# or extract keys from packed command
777778
self._conn.send_packed_command(command)
778779

779780
def send_command(self, *args, **kwargs):
780781
self._process_pending_invalidations()
781782

782-
# If command is write command or not allowed to cache, transfer control to the actual connection.
783+
# If command is write command or not allowed to cache
784+
# transfer control to the actual connection.
783785
if not self._conf.is_allowed_to_cache(args[0]):
784786
self._current_command_hash = None
785787
self._current_command_keys = None
@@ -797,14 +799,17 @@ def send_command(self, *args, **kwargs):
797799
raise TypeError("Cache keys must be a list.")
798800

799801
with self._cache_lock:
800-
# If current command reply already cached prevent sending data over socket.
802+
# If current command reply already cached
803+
# prevent sending data over socket.
801804
if self._cache.get(self._current_command_hash):
802805
return
803806

804-
# Set temporary entry as a status to prevent race condition from another connection.
807+
# Set temporary entry as a status to prevent
808+
# race condition from another connection.
805809
self._cache[self._current_command_hash] = "caching-in-progress"
806810

807-
# Send command over socket only if it's allowed read-only command that not yet cached.
811+
# Send command over socket only if it's allowed
812+
# read-only command that not yet cached.
808813
self._conn.send_command(*args, **kwargs)
809814

810815
def can_read(self, timeout=0):
@@ -836,7 +841,8 @@ def read_response(
836841
elif self._current_command_hash is None:
837842
return response
838843

839-
# Create separate mapping for keys or add current response to associated keys.
844+
# Create separate mapping for keys
845+
# or add current response to associated keys.
840846
for key in self._current_command_keys:
841847
if key in self._keys_mapping:
842848
if self._current_command_hash not in self._keys_mapping[key]:
@@ -846,7 +852,8 @@ def read_response(
846852

847853
cache_entry = self._cache.get(self._current_command_hash, None)
848854

849-
# Cache only responses that still valid and wasn't invalidated by another connection in meantime.
855+
# Cache only responses that still valid
856+
# and wasn't invalidated by another connection in meantime.
850857
if cache_entry is not None:
851858
self._cache[self._current_command_hash] = response
852859

tests/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ def _get_client(
330330
connection_class = SSLConnection
331331
kwargs["ssl_certfile"] = get_ssl_filename("client-cert.pem")
332332
kwargs["ssl_keyfile"] = get_ssl_filename("client-key.pem")
333-
# When you try to assign "required" as single string, it assigns tuple instead of string.
334-
# Probably some reserved keyword, I can't explain how does it work -_-
333+
# When you try to assign "required" as single string
334+
# it assigns tuple instead of string.
335+
# Probably some reserved keyword
336+
# I can't explain how does it work -_-
335337
kwargs["ssl_cert_reqs"] = "require" + "d"
336338
kwargs["ssl_ca_certs"] = get_ssl_filename("ca-cert.pem")
337339
kwargs["port"] = 6666

tests/test_cache.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ def test_cache_invalidate_all_related_responses(self, r):
425425
res.append(b"baz")
426426
assert another_res != res
427427

428-
# Invalidate one of the keys and make sure that all associated cached entries was removed
428+
# Invalidate one of the keys and make sure that
429+
# all associated cached entries was removed
429430
assert r.set("foo", "baz")
430431
assert r.get("foo") == b"baz"
431432
assert cache.get(("MGET", "foo", "bar")) is None
@@ -743,7 +744,8 @@ def test_cache_invalidate_all_related_responses(self, r, cache):
743744
assert r.mget("foo{slot}", "bar{slot}") == [b"bar", b"foo"]
744745
assert cache.get(("MGET", "foo{slot}", "bar{slot}")) == [b"bar", b"foo"]
745746

746-
# Invalidate one of the keys and make sure that all associated cached entries was removed
747+
# Invalidate one of the keys and make sure
748+
# that all associated cached entries was removed
747749
assert r.set("foo{slot}", "baz")
748750
assert r.get("foo{slot}") == b"baz"
749751
assert cache.get(("MGET", "foo{slot}", "bar{slot}")) is None
@@ -1133,7 +1135,8 @@ def test_cache_invalidate_all_related_responses(self, r):
11331135
assert r.mget("foo", "bar") == [b"bar", b"foo"]
11341136
assert cache.get(("MGET", "foo", "bar")) == [b"bar", b"foo"]
11351137

1136-
# Invalidate one of the keys and make sure that all associated cached entries was removed
1138+
# Invalidate one of the keys and make sure
1139+
# that all associated cached entries was removed
11371140
assert r.set("foo", "baz")
11381141
assert r.get("foo") == b"baz"
11391142
assert cache.get(("MGET", "foo", "bar")) is None

0 commit comments

Comments
 (0)