Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RedisClient

Redis client which wraps node_redis client and handles:
- connection
- disconnection
- event listeners
- logging

Hierarchy

  • RedisClient

Constructors

constructor

Accessors

client

  • get client(): NodeRedisClient

connectionOptions

db

  • get db(): string | number

debug

  • get debug(): boolean
  • set debug(enable: boolean): void
  • Check whether redis is in debug_mode.

    Returns boolean

  • Enable/Disable redis debug_mode.

    Parameters

    • enable: boolean

      Whether to enable.

    Returns void

publisher

  • get publisher(): NodeRedisClient

subscriber

  • get subscriber(): NodeRedisClient

Methods

connect

disconnect

  • disconnect(graceful?: boolean): Promise<void>
  • Disconnect from Redis server.
    Closes all of the earlier established connections.

    Parameters

    • graceful: boolean = true

      Whether to perform graceful disconnect.

    Returns Promise<void>

on

  • Attach listener for event on connectionType.
    This method is made because application modules tend to register listeners before connections are established. Connection is made from the client constructor, meaning that on listeners registering clients are not created yet. Therefore, listeners are queued before connections are established, and then registered. In case connection is established already, they will be registered on it and skip the queueing phase.

    Parameters

    • connectionType: ConnectionType

      Connection on which listener needs to be registered.

    • event: "message" | "message_buffer"

      Event name.

    • listener: function

      Event listener.

        • (channel: string, message: string): void
        • Parameters

          • channel: string
          • message: string

          Returns void

    Returns RedisClient

  • Attach listener for event on connectionType.
    This method is made because application modules tend to register listeners before connections are established. Connection is made from the client constructor, meaning that on listeners registering clients are not created yet. Therefore, listeners are queued before connections are established, and then registered. In case connection is established already, they will be registered on it and skip the queueing phase.

    Parameters

    • connectionType: ConnectionType

      Connection on which listener needs to be registered.

    • event: "pmessage" | "pmessage_buffer"

      Event name.

    • listener: function

      Event listener.

        • (pattern: string, channel: string, message: string): void
        • Parameters

          • pattern: string
          • channel: string
          • message: string

          Returns void

    Returns RedisClient

  • Attach listener for event on connectionType.
    This method is made because application modules tend to register listeners before connections are established. Connection is made from the client constructor, meaning that on listeners registering clients are not created yet. Therefore, listeners are queued before connections are established, and then registered. In case connection is established already, they will be registered on it and skip the queueing phase.

    Parameters

    • connectionType: ConnectionType

      Connection on which listener needs to be registered.

    • event: "subscribe" | "unsubscribe"

      Event name.

    • listener: function

      Event listener.

        • (channel: string, count: number): void
        • Parameters

          • channel: string
          • count: number

          Returns void

    Returns RedisClient

  • Attach listener for event on connectionType.
    This method is made because application modules tend to register listeners before connections are established. Connection is made from the client constructor, meaning that on listeners registering clients are not created yet. Therefore, listeners are queued before connections are established, and then registered. In case connection is established already, they will be registered on it and skip the queueing phase.

    Parameters

    • connectionType: ConnectionType

      Connection on which listener needs to be registered.

    • event: "psubscribe" | "punsubscribe"

      Event name.

    • listener: function

      Event listener.

        • (pattern: string, count: number): void
        • Parameters

          • pattern: string
          • count: number

          Returns void

    Returns RedisClient