redis/redis-py · error · NotImplementedError

MEMORY DOCTOR is intentionally not implemented in the client

Error message

MEMORY DOCTOR is intentionally not implemented in the client. For more information, see https://redis.io/commands/memory-doctor

What it means

memory_doctor is a stub that always raises NotImplementedError. MEMORY DOCTOR returns a human-readable memory diagnostic report intended for redis-cli; it is not structured data, so redis-py does not wrap it as a client method.

Source

Thrown at redis/commands/core.py:1868

    @overload
    def object(self: SyncClientProtocol, infotype: str, key: KeyT, **kwargs) -> Any: ...

    @overload
    def object(
        self: AsyncClientProtocol, infotype: str, key: KeyT, **kwargs
    ) -> Awaitable[Any]: ...

    def object(self, infotype: str, key: KeyT, **kwargs) -> Any | Awaitable[Any]:
        """
        Return the encoding, idletime, or refcount about the key
        """
        return self.execute_command(
            "OBJECT", infotype, key, infotype=infotype, **kwargs
        )

    def memory_doctor(self, **kwargs) -> None:
        raise NotImplementedError(
            """
            MEMORY DOCTOR is intentionally not implemented in the client.

            For more information, see https://redis.io/commands/memory-doctor
            """
        )

    def memory_help(self, **kwargs) -> None:
        raise NotImplementedError(
            """
            MEMORY HELP is intentionally not implemented in the client.

            For more information, see https://redis.io/commands/memory-help
            """
        )

    @overload
    def memory_stats(self: SyncClientProtocol, **kwargs) -> dict[str, Any]: ...

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Use r.execute_command('MEMORY', 'DOCTOR') for the raw text report.
  2. For structured memory stats, use r.memory_stats() or r.memory_usage(key).
  3. Use redis-cli for the human-readable report.

Example fix

# before
r.memory_doctor()
# after
report = r.execute_command('MEMORY', 'DOCTOR')
Defensive patterns

Strategy: fallback

Try / catch

try:
    r.memory_doctor()
except NotImplementedError:
    report = r.execute_command('MEMORY', 'DOCTOR')

Prevention

When it happens

Trigger: Calling r.memory_doctor(). Building a memory-monitoring tool and invoking the obvious method.

Common situations: Operator wants programmatic memory diagnostics. Copying redis-cli MEMORY DOCTOR workflow into Python. Enumerating memory_* methods.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/76fbd87ce1e2dbf8.json. Report an issue: GitHub.