Skip to content

Commit 4e9cc01

Browse files
authored
Removing command on initial connections (#1722)
1 parent e74ed19 commit 4e9cc01

File tree

3 files changed

+2
-32
lines changed

3 files changed

+2
-32
lines changed

redis/client.py

-18
Original file line numberDiff line numberDiff line change
@@ -890,12 +890,6 @@ def __init__(self, host='localhost', port=6379,
890890
self.response_callbacks = CaseInsensitiveDict(
891891
self.__class__.RESPONSE_CALLBACKS)
892892

893-
# preload our class with the available redis commands
894-
try:
895-
self.__redis_commands__()
896-
except RedisError:
897-
pass
898-
899893
def __repr__(self):
900894
return "%s<%s>" % (type(self).__name__, repr(self.connection_pool))
901895

@@ -927,18 +921,6 @@ def load_external_module(self, funcname, func,
927921
"""
928922
setattr(self, funcname, func)
929923

930-
def __redis_commands__(self):
931-
"""Store the list of available commands, for our redis instance."""
932-
cmds = getattr(self, '__commands__', None)
933-
if cmds is not None:
934-
return cmds
935-
try:
936-
cmds = [c[0].upper().decode() for c in self.command()]
937-
except AttributeError: # if encoded
938-
cmds = [c[0].upper() for c in self.command()]
939-
self.__commands__ = cmds
940-
return cmds
941-
942924
def pipeline(self, transaction=True, shard_hint=None):
943925
"""
944926
Return a new pipeline object that can queue multiple commands for

redis/commands/redismodules.py

-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from json import JSONEncoder, JSONDecoder
2-
from redis.exceptions import ModuleError
32

43

54
class RedisModuleCommands:
@@ -10,10 +9,6 @@ class RedisModuleCommands:
109
def json(self, encoder=JSONEncoder(), decoder=JSONDecoder()):
1110
"""Access the json namespace, providing support for redis json.
1211
"""
13-
if 'JSON.SET' not in self.__commands__:
14-
raise ModuleError("redisjson is not loaded in redis. "
15-
"For more information visit "
16-
"https://redisjson.io/")
1712

1813
from .json import JSON
1914
jj = JSON(
@@ -25,10 +20,6 @@ def json(self, encoder=JSONEncoder(), decoder=JSONDecoder()):
2520
def ft(self, index_name="idx"):
2621
"""Access the search namespace, providing support for redis search.
2722
"""
28-
if 'FT.INFO' not in self.__commands__:
29-
raise ModuleError("redisearch is not loaded in redis. "
30-
"For more information visit "
31-
"https://redisearch.io/")
3223

3324
from .search import Search
3425
s = Search(client=self, index_name=index_name)
@@ -38,10 +29,6 @@ def ts(self):
3829
"""Access the timeseries namespace, providing support for
3930
redis timeseries data.
4031
"""
41-
if 'TS.INFO' not in self.__commands__:
42-
raise ModuleError("reditimeseries is not loaded in redis. "
43-
"For more information visit "
44-
"https://redistimeseries.io/")
4532

4633
from .timeseries import TimeSeries
4734
s = TimeSeries(client=self)

tests/conftest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def pytest_addoption(parser):
3131
def _get_info(redis_url):
3232
client = redis.Redis.from_url(redis_url)
3333
info = client.info()
34-
if 'dping' in client.__commands__:
34+
cmds = [c[0].upper().decode() for c in client.command()]
35+
if 'dping' in cmds:
3536
info["enterprise"] = True
3637
else:
3738
info["enterprise"] = False

0 commit comments

Comments
 (0)