图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.4 KiB

  1. from json import JSONDecoder, JSONEncoder
  2. class RedisModuleCommands:
  3. """This class contains the wrapper functions to bring supported redis
  4. modules into the command namespace.
  5. """
  6. def json(self, encoder=JSONEncoder(), decoder=JSONDecoder()):
  7. """Access the json namespace, providing support for redis json."""
  8. from .json import JSON
  9. jj = JSON(client=self, encoder=encoder, decoder=decoder)
  10. return jj
  11. def ft(self, index_name="idx"):
  12. """Access the search namespace, providing support for redis search."""
  13. from .search import Search
  14. s = Search(client=self, index_name=index_name)
  15. return s
  16. def ts(self):
  17. """Access the timeseries namespace, providing support for
  18. redis timeseries data.
  19. """
  20. from .timeseries import TimeSeries
  21. s = TimeSeries(client=self)
  22. return s
  23. def bf(self):
  24. """Access the bloom namespace."""
  25. from .bf import BFBloom
  26. bf = BFBloom(client=self)
  27. return bf
  28. def cf(self):
  29. """Access the bloom namespace."""
  30. from .bf import CFBloom
  31. cf = CFBloom(client=self)
  32. return cf
  33. def cms(self):
  34. """Access the bloom namespace."""
  35. from .bf import CMSBloom
  36. cms = CMSBloom(client=self)
  37. return cms
  38. def topk(self):
  39. """Access the bloom namespace."""
  40. from .bf import TOPKBloom
  41. topk = TOPKBloom(client=self)
  42. return topk
  43. def tdigest(self):
  44. """Access the bloom namespace."""
  45. from .bf import TDigestBloom
  46. tdigest = TDigestBloom(client=self)
  47. return tdigest
  48. def graph(self, index_name="idx"):
  49. """Access the graph namespace, providing support for
  50. redis graph data.
  51. """
  52. from .graph import Graph
  53. g = Graph(client=self, name=index_name)
  54. return g
  55. class AsyncRedisModuleCommands(RedisModuleCommands):
  56. def ft(self, index_name="idx"):
  57. """Access the search namespace, providing support for redis search."""
  58. from .search import AsyncSearch
  59. s = AsyncSearch(client=self, index_name=index_name)
  60. return s
  61. def graph(self, index_name="idx"):
  62. """Access the graph namespace, providing support for
  63. redis graph data.
  64. """
  65. from .graph import AsyncGraph
  66. g = AsyncGraph(client=self, name=index_name)
  67. return g