summaryrefslogtreecommitdiff
path: root/redis/commands/redismodules.py
blob: fb53107130a3df6efba723fdb6f6fbf538c88fcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from json import JSONEncoder, JSONDecoder
from redis.exceptions import ModuleError


class RedisModuleCommands:
    """This class contains the wrapper functions to bring supported redis
    modules into the command namepsace.
    """

    def json(self, encoder=JSONEncoder(), decoder=JSONDecoder()):
        """Access the json namespace, providing support for redis json."""
        if 'rejson' not in self.loaded_modules:
            raise ModuleError("rejson is not a loaded in the redis instance.")

        from .json import JSON
        jj = JSON(client=self, encoder=encoder, decoder=decoder)
        return jj