glh123456/OmniGIRL huggingface dataset:
Repository: redis/redis-py (Python)

Issue:
CONFIG GET - add the ability to pass multiple pattern parameters in one call



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -760,13 +760,15 @@ def command_docs(self, *args):
             "COMMAND DOCS is intentionally not implemented in the client."
         )
 
-    def config_get(self, pattern: PatternT = "*", **kwargs) -> ResponseT:
+    def config_get(
+        self, pattern: PatternT = "*", *args: List[PatternT], **kwargs
+    ) -> ResponseT:
         """
         Return a dictionary of configuration based on the ``pattern``
 
         For more information see https://redis.io/commands/config-get
         """
-        return self.execute_command("CONFIG GET", pattern, **kwargs)
+        return self.execute_command("CONFIG GET", pattern, *args, **kwargs)
 
     def config_set(self, name: KeyT, value: EncodableT, **kwargs) -> ResponseT:
         """Set config item ``name`` with ``value``


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -669,6 +669,12 @@ def test_config_get(self, r):
         # # assert 'maxmemory' in data
         # assert data['maxmemory'].isdigit()
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_config_get_multi_params(self, r: redis.Redis):
+        res = r.config_get("*max-*-entries*", "maxmemory")
+        assert "maxmemory" in res
+        assert "hash-max-listpack-entries" in res
+
     @pytest.mark.onlynoncluster
     @skip_if_redis_enterprise()
     def test_config_resetstat(self, r):
Repository: redis/redis-py (Python)

Issue:
CONFIG SET - add the ability to set multiple parameters in one call



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -770,12 +770,18 @@ def config_get(
         """
         return self.execute_command("CONFIG GET", pattern, *args, **kwargs)
 
-    def config_set(self, name: KeyT, value: EncodableT, **kwargs) -> ResponseT:
+    def config_set(
+        self,
+        name: KeyT,
+        value: EncodableT,
+        *args: List[Union[KeyT, EncodableT]],
+        **kwargs,
+    ) -> ResponseT:
         """Set config item ``name`` with ``value``
 
         For more information see https://redis.io/commands/config-set
         """
-        return self.execute_command("CONFIG SET", name, value, **kwargs)
+        return self.execute_command("CONFIG SET", name, value, *args, **kwargs)
 
     def config_resetstat(self, **kwargs) -> ResponseT:
         """


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -692,6 +692,16 @@ def test_config_set(self, r):
         assert r.config_set("timeout", 0)
         assert r.config_get()["timeout"] == "0"
 
+    @skip_if_server_version_lt("7.0.0")
+    @skip_if_redis_enterprise()
+    def test_config_set_multi_params(self, r: redis.Redis):
+        r.config_set("timeout", 70, "maxmemory", 100)
+        assert r.config_get()["timeout"] == "70"
+        assert r.config_get()["maxmemory"] == "100"
+        assert r.config_set("timeout", 0, "maxmemory", 0)
+        assert r.config_get()["timeout"] == "0"
+        assert r.config_get()["maxmemory"] == "0"
+
     @skip_if_server_version_lt("6.0.0")
     @skip_if_redis_enterprise()
     def test_failover(self, r):
Repository: redis/redis-py (Python)

Issue:
INFO - add support for taking multiple section arguments



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -900,7 +900,9 @@ def select(self, index: int, **kwargs) -> ResponseT:
         """
         return self.execute_command("SELECT", index, **kwargs)
 
-    def info(self, section: Union[str, None] = None, **kwargs) -> ResponseT:
+    def info(
+        self, section: Union[str, None] = None, *args: List[str], **kwargs
+    ) -> ResponseT:
         """
         Returns a dictionary containing information about the Redis server
 
@@ -915,7 +917,7 @@ def info(self, section: Union[str, None] = None, **kwargs) -> ResponseT:
         if section is None:
             return self.execute_command("INFO", **kwargs)
         else:
-            return self.execute_command("INFO", section, **kwargs)
+            return self.execute_command("INFO", section, *args, **kwargs)
 
     def lastsave(self, **kwargs) -> ResponseT:
         """


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -727,6 +727,14 @@ def test_info(self, r):
         assert "arch_bits" in info.keys()
         assert "redis_version" in info.keys()
 
+    @pytest.mark.onlynoncluster
+    @skip_if_server_version_lt("7.0.0")
+    def test_info_multi_sections(self, r):
+        res = r.info("clients", "server")
+        assert isinstance(res, dict)
+        assert "redis_version" in res
+        assert "connected_clients" in res
+
     @pytest.mark.onlynoncluster
     @skip_if_redis_enterprise()
     def test_lastsave(self, r):
Repository: redis/redis-py (Python)

Issue:
Add support for MODULE LOADEX



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -5592,6 +5592,27 @@ def module_load(self, path, *args) -> ResponseT:
         """
         return self.execute_command("MODULE LOAD", path, *args)
 
+    def module_loadex(
+        self,
+        path: str,
+        options: Optional[List[str]] = None,
+        args: Optional[List[str]] = None,
+    ) -> ResponseT:
+        """
+        Loads a module from a dynamic library at runtime with configuration directives.
+
+        For more information see https://redis.io/commands/module-loadex
+        """
+        pieces = []
+        if options is not None:
+            pieces.append("CONFIG")
+            pieces.extend(options)
+        if args is not None:
+            pieces.append("ARGS")
+            pieces.extend(args)
+
+        return self.execute_command("MODULE LOADEX", path, *pieces)
+
     def module_unload(self, name) -> ResponseT:
         """
         Unloads the module ``name``.


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -4513,6 +4513,18 @@ def test_module(self, r):
             r.module_load("/some/fake/path", "arg1", "arg2", "arg3", "arg4")
             assert "Error loading the extension." in str(excinfo.value)
 
+    @pytest.mark.onlynoncluster
+    @skip_if_server_version_lt("7.0.0")
+    @skip_if_redis_enterprise()
+    def test_module_loadex(self, r: redis.Redis):
+        with pytest.raises(redis.exceptions.ModuleError) as excinfo:
+            r.module_loadex("/some/fake/path")
+            assert "Error loading the extension." in str(excinfo.value)
+
+        with pytest.raises(redis.exceptions.ModuleError) as excinfo:
+            r.module_loadex("/some/fake/path", ["name", "value"], ["arg1", "arg2"])
+            assert "Error loading the extension." in str(excinfo.value)
+
     @skip_if_server_version_lt("2.6.0")
     def test_restore(self, r):
Repository: redis/redis-py (Python)

Issue:
Add support for LATENCY HISTOGRAM



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1044,6 +1044,15 @@ def memory_purge(self, **kwargs) -> ResponseT:
         """
         return self.execute_command("MEMORY PURGE", **kwargs)
 
+    def latency_histogram(self, *args):
+        """
+        This function throws a NotImplementedError since it is intentionally
+        not supported.
+        """
+        raise NotImplementedError(
+            "LATENCY HISTOGRAM is intentionally not implemented in the client."
+        )
+
     def ping(self, **kwargs) -> ResponseT:
         """
         Ping the Redis server


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -4420,6 +4420,11 @@ def test_memory_usage(self, r):
         r.set("foo", "bar")
         assert isinstance(r.memory_usage("foo"), int)
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_latency_histogram_not_implemented(self, r: redis.Redis):
+        with pytest.raises(NotImplementedError):
+            r.latency_histogram()
+
     @pytest.mark.onlynoncluster
     @skip_if_server_version_lt("4.0.0")
     @skip_if_redis_enterprise()
Repository: redis/redis-py (Python)

Issue:
Add support for missing command BITFIELD_RO



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1504,6 +1504,29 @@ def bitfield(
         """
         return BitFieldOperation(self, key, default_overflow=default_overflow)
 
+    def bitfield_ro(
+        self: Union["Redis", "AsyncRedis"],
+        key: KeyT,
+        encoding: str,
+        offset: BitfieldOffsetT,
+        items: Optional[list] = None,
+    ) -> ResponseT:
+        """
+        Return an array of the specified bitfield values
+        where the first value is found using ``encoding`` and ``offset``
+        parameters and remaining values are result of corresponding
+        encoding/offset pairs in optional list ``items``
+        Read-only variant of the BITFIELD command.
+
+        For more information see https://redis.io/commands/bitfield_ro
+        """
+        params = [key, "GET", encoding, offset]
+
+        items = items or []
+        for encoding, offset in items:
+            params.extend(["GET", encoding, offset])
+        return self.execute_command("BITFIELD_RO", *params)
+
     def bitop(self, operation: str, dest: KeyT, *keys: KeyT) -> ResponseT:
         """
         Perform a bitwise operation using ``operation`` between ``keys`` and


Test patch:
diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py
--- a/tests/test_asyncio/test_commands.py
+++ b/tests/test_asyncio/test_commands.py
@@ -2953,6 +2953,19 @@ async def test_bitfield_operations(self, r: redis.Redis):
         )
         assert resp == [0, None, 255]
 
+    @skip_if_server_version_lt("6.0.0")
+    async def test_bitfield_ro(self, r: redis.Redis):
+        bf = r.bitfield("a")
+        resp = await bf.set("u8", 8, 255).execute()
+        assert resp == [0]
+
+        resp = await r.bitfield_ro("a", "u8", 0)
+        assert resp == [0]
+
+        items = [("u4", 8), ("u4", 12), ("u4", 13)]
+        resp = await r.bitfield_ro("a", "u8", 0, items)
+        assert resp == [0, 15, 15, 14]
+
     @skip_if_server_version_lt("4.0.0")
     async def test_memory_stats(self, r: redis.Redis):
         # put a key into the current db to make sure that "db.<current-db>"
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -4438,6 +4438,19 @@ def test_bitfield_operations(self, r):
         )
         assert resp == [0, None, 255]
 
+    @skip_if_server_version_lt("6.0.0")
+    def test_bitfield_ro(self, r: redis.Redis):
+        bf = r.bitfield("a")
+        resp = bf.set("u8", 8, 255).execute()
+        assert resp == [0]
+
+        resp = r.bitfield_ro("a", "u8", 0)
+        assert resp == [0]
+
+        items = [("u4", 8), ("u4", 12), ("u4", 13)]
+        resp = r.bitfield_ro("a", "u8", 0, items)
+        assert resp == [0, 15, 15, 14]
+
     @skip_if_server_version_lt("4.0.0")
     def test_memory_help(self, r):
         with pytest.raises(NotImplementedError):
Repository: redis/redis-py (Python)

Issue:
Add support for missing command LATENCY DOCTOR



Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -980,6 +980,34 @@ def lastsave(self, **kwargs) -> ResponseT:
         """
         return self.execute_command("LASTSAVE", **kwargs)
 
+    def latency_doctor(self):
+        """Raise a NotImplementedError, as the client will not support LATENCY DOCTOR.
+        This funcion is best used within the redis-cli.
+
+        For more information see https://redis.io/commands/latency-doctor
+        """
+        raise NotImplementedError(
+            """
+            LATENCY DOCTOR is intentionally not implemented in the client.
+
+            For more information see https://redis.io/commands/latency-doctor
+            """
+        )
+
+    def latency_graph(self):
+        """Raise a NotImplementedError, as the client will not support LATENCY GRAPH.
+        This funcion is best used within the redis-cli.
+
+        For more information see https://redis.io/commands/latency-graph.
+        """
+        raise NotImplementedError(
+            """
+            LATENCY GRAPH is intentionally not implemented in the client.
+
+            For more information see https://redis.io/commands/latency-graph
+            """
+        )
+
     def lolwut(self, *version_numbers: Union[str, float], **kwargs) -> ResponseT:
         """
         Get the Redis version and a piece of generative computer art


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -4527,6 +4527,16 @@ def test_latency_histogram_not_implemented(self, r: redis.Redis):
         with pytest.raises(NotImplementedError):
             r.latency_histogram()
 
+    @skip_if_server_version_lt("7.0.0")
+    def test_latency_graph_not_implemented(self, r: redis.Redis):
+        with pytest.raises(NotImplementedError):
+            r.latency_graph()
+
+    @skip_if_server_version_lt("7.0.0")
+    def test_latency_doctor_not_implemented(self, r: redis.Redis):
+        with pytest.raises(NotImplementedError):
+            r.latency_doctor()
+
     @pytest.mark.onlynoncluster
     @skip_if_server_version_lt("4.0.0")
     @skip_if_redis_enterprise()
Repository: redis/redis-py (Python)

Issue:
Add support for missing command LATENCY RESET



Hints:

Patch:
diff --git a/redis/cluster.py b/redis/cluster.py
--- a/redis/cluster.py
+++ b/redis/cluster.py
@@ -265,6 +265,9 @@ class AbstractRedisCluster:
                 "READWRITE",
                 "TIME",
                 "GRAPH.CONFIG",
+                "LATENCY HISTORY",
+                "LATENCY LATEST",
+                "LATENCY RESET",
             ],
             DEFAULT_NODE,
         ),
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1151,6 +1151,30 @@ def latency_histogram(self, *args):
             "LATENCY HISTOGRAM is intentionally not implemented in the client."
         )
 
+    def latency_history(self, event: str) -> ResponseT:
+        """
+        Returns the raw data of the ``event``'s latency spikes time series.
+
+        For more information see https://redis.io/commands/latency-history
+        """
+        return self.execute_command("LATENCY HISTORY", event)
+
+    def latency_latest(self) -> ResponseT:
+        """
+        Reports the latest latency events logged.
+
+        For more information see https://redis.io/commands/latency-latest
+        """
+        return self.execute_command("LATENCY LATEST")
+
+    def latency_reset(self, *events: str) -> ResponseT:
+        """
+        Resets the latency spikes time series of all, or only some, events.
+
+        For more information see https://redis.io/commands/latency-reset
+        """
+        return self.execute_command("LATENCY RESET", *events)
+
     def ping(self, **kwargs) -> ResponseT:
         """
         Ping the Redis server


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -4527,16 +4527,23 @@ def test_latency_histogram_not_implemented(self, r: redis.Redis):
         with pytest.raises(NotImplementedError):
             r.latency_histogram()
 
-    @skip_if_server_version_lt("7.0.0")
     def test_latency_graph_not_implemented(self, r: redis.Redis):
         with pytest.raises(NotImplementedError):
             r.latency_graph()
 
-    @skip_if_server_version_lt("7.0.0")
     def test_latency_doctor_not_implemented(self, r: redis.Redis):
         with pytest.raises(NotImplementedError):
             r.latency_doctor()
 
+    def test_latency_history(self, r: redis.Redis):
+        assert r.latency_history("command") == []
+
+    def test_latency_latest(self, r: redis.Redis):
+        assert r.latency_latest() == []
+
+    def test_latency_reset(self, r: redis.Redis):
+        assert r.latency_reset() == 0
+
     @pytest.mark.onlynoncluster
     @skip_if_server_version_lt("4.0.0")
     @skip_if_redis_enterprise()
Repository: redis/redis-py (Python)

Issue:
`set` and `expire` api diffrent handle to 'expire time' param

expire: https://github.com/redis/redis-py/blob/42b937fa1f73f3e8251eba5ec8ead2fcbaec7c50/redis/commands/core.py#L1592
set: https://github.com/redis/redis-py/blob/42b937fa1f73f3e8251eba5ec8ead2fcbaec7c50/redis/commands/core.py#L2175

The `set` api `ex`  should be a interger, but `expire`'s `time` can use a string(integer in  string type) as input.

It make me confusing. Both can also accept string type is more convenient.






Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -2255,6 +2255,8 @@ def set(
                 pieces.append(int(ex.total_seconds()))
             elif isinstance(ex, int):
                 pieces.append(ex)
+            elif isinstance(ex, str) and ex.isdigit():
+                pieces.append(int(ex))
             else:
                 raise DataError("ex must be datetime.timedelta or int")
         if px is not None:


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1600,6 +1600,13 @@ def test_set_ex(self, r):
         with pytest.raises(exceptions.DataError):
             assert r.set("a", "1", ex=10.0)
 
+    @skip_if_server_version_lt("2.6.0")
+    def test_set_ex_str(self, r):
+        assert r.set("a", "1", ex="10")
+        assert 0 < r.ttl("a") <= 10
+        with pytest.raises(exceptions.DataError):
+            assert r.set("a", "1", ex="10.5")
+
     @skip_if_server_version_lt("2.6.0")
     def test_set_ex_timedelta(self, r):
         expire_at = datetime.timedelta(seconds=60)
Repository: redis/redis-py (Python)

Issue:
Add support for new redis command CLIENT NO-TOUCH
7.2.0 adds support for the new redis command CLIENT NO-TOUCH. We need to add support, documented [here](https://redis.io/commands/CLIENT-NO-TOUCH).


Hints:

Patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -761,6 +761,17 @@ def client_no_evict(self, mode: str) -> Union[Awaitable[str], str]:
         """
         return self.execute_command("CLIENT NO-EVICT", mode)
 
+    def client_no_touch(self, mode: str) -> Union[Awaitable[str], str]:
+        """
+        # The command controls whether commands sent by the client will alter
+        # the LRU/LFU of the keys they access.
+        # When turned on, the current client will not change LFU/LRU stats,
+        # unless it sends the TOUCH command.
+
+        For more information see https://redis.io/commands/client-no-touch
+        """
+        return self.execute_command("CLIENT NO-TOUCH", mode)
+
     def command(self, **kwargs):
         """
         Returns dict reply of details about all Redis commands.


Test patch:
diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py
--- a/tests/test_asyncio/test_commands.py
+++ b/tests/test_asyncio/test_commands.py
@@ -446,6 +446,14 @@ async def test_client_pause(self, r: redis.Redis):
         with pytest.raises(exceptions.RedisError):
             await r.client_pause(timeout="not an integer")
 
+    @skip_if_server_version_lt("7.2.0")
+    @pytest.mark.onlynoncluster
+    async def test_client_no_touch(self, r: redis.Redis):
+        assert await r.client_no_touch("ON") == b"OK"
+        assert await r.client_no_touch("OFF") == b"OK"
+        with pytest.raises(TypeError):
+            await r.client_no_touch()
+
     async def test_config_get(self, r: redis.Redis):
         data = await r.config_get()
         assert "maxmemory" in data
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -693,6 +693,14 @@ def test_client_no_evict(self, r):
         with pytest.raises(TypeError):
             r.client_no_evict()
 
+    @pytest.mark.onlynoncluster
+    @skip_if_server_version_lt("7.2.0")
+    def test_client_no_touch(self, r):
+        assert r.client_no_touch("ON") == b"OK"
+        assert r.client_no_touch("OFF") == b"OK"
+        with pytest.raises(TypeError):
+            r.client_no_touch()
+
     @pytest.mark.onlynoncluster
     @skip_if_server_version_lt("3.2.0")
     def test_client_reply(self, r, r_timeout):
Repository: redis/redis-py (Python)

Issue:
Redis.from_url() is a misnomer
**Version**: 4.5.2

**Platform**: Python 3.11.2

**Description**: Redis.from_url is a convenience function, but the kwargs are passed into the ConnectionPool object and not the Redis instance. This formerly wasn't a problem, but it appears as though auto_close_connection_pool now defaults to true, so you can't reliably use Redis.from_url() in a singleton. 



Hints:

Patch:
diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py
--- a/redis/asyncio/client.py
+++ b/redis/asyncio/client.py
@@ -139,8 +139,12 @@ class initializer. In the case of conflicting arguments, querystring
         arguments always win.
 
         """
+        single_connection_client = kwargs.pop("single_connection_client", False)
         connection_pool = ConnectionPool.from_url(url, **kwargs)
-        return cls(connection_pool=connection_pool)
+        return cls(
+            connection_pool=connection_pool,
+            single_connection_client=single_connection_client,
+        )
 
     def __init__(
         self,
diff --git a/redis/client.py b/redis/client.py
--- a/redis/client.py
+++ b/redis/client.py
@@ -899,8 +899,12 @@ class initializer. In the case of conflicting arguments, querystring
         arguments always win.
 
         """
+        single_connection_client = kwargs.pop("single_connection_client", False)
         connection_pool = ConnectionPool.from_url(url, **kwargs)
-        return cls(connection_pool=connection_pool)
+        return cls(
+            connection_pool=connection_pool,
+            single_connection_client=single_connection_client,
+        )
 
     def __init__(
         self,


Test patch:
diff --git a/tests/test_asyncio/test_connection.py b/tests/test_asyncio/test_connection.py
--- a/tests/test_asyncio/test_connection.py
+++ b/tests/test_asyncio/test_connection.py
@@ -271,3 +271,9 @@ async def open_connection(*args, **kwargs):
 
     vals = await asyncio.gather(do_read(), do_close())
     assert vals == [b"Hello, World!", None]
+
+
+@pytest.mark.onlynoncluster
+def test_create_single_connection_client_from_url():
+    client = Redis.from_url("redis://localhost:6379/0?", single_connection_client=True)
+    assert client.single_connection_client is True
diff --git a/tests/test_connection.py b/tests/test_connection.py
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -205,3 +205,11 @@ def test_pack_command(Class):
 
     actual = Class().pack_command(*cmd)[0]
     assert actual == expected, f"actual = {actual}, expected = {expected}"
+
+
+@pytest.mark.onlynoncluster
+def test_create_single_connection_client_from_url():
+    client = redis.Redis.from_url(
+        "redis://localhost:6379/0?", single_connection_client=True
+    )
+    assert client.connection is not None