Updated on 2024-02-08 GMT+08:00

Keyspace Notification

The keyspace notification function is available on all clients that support subscription and release, without any modification.

Precautions

  • The keyspace notification function is disabled by default because it consumes CPU resources if enabled.
  • Do not enable the keyspace notification in high-pressure scenarios. Enabling this function will affect instance performance, and some event notifications may be missed.

Differences from Open-source Redis

  1. Configuration methods

    Run CONFIG SET to enable or disable the keyspace notification.

    Config set notify-keyspace-events Ex

    • The keyspace notification is disabled if notify-keyspace-events is empty or does not contain K and E.
      • Double quotation marks indicate that the parameter is an empty string.
      • The GeminiDB Redis console client does not allow you to disable the keyspace notification by setting notify-keyspace-events to an empty string.
    • The keyspace notification is enabled if notify-keyspace-events is not empty and is correctly configured. For details, see Table 1.
  2. Notification Types
    Table 1 Supported notification types

    Character

    Notification

    Supported by GeminiDB Redis

    K

    Keyspace notification. All notifications are prefixed by __keyspace@__.

    Yes

    E

    Key event notification. All notifications are prefixed by __keyevent@<db>__ .

    Yes

    g

    Notifications for generic commands such as DEL, EXPIRE, and RENAME

    Yes

    $

    Notifications for string commands

    Yes

    l

    Notifications for list commands

    Yes

    s

    Notifications for set commands

    Yes

    h

    Notifications for hash commands

    Yes

    z

    Notifications for sorted set commands

    Yes

    x

    EXPIRED event notifications

    Yes

    e

    EVICT event notifications

    N/A

    A

    Alias for parameter g$lshzxe

    Yes

    As shown in Table 1, EVICT event notifications are not applicable for the current version of GeminiDB Redis.

    The parameter value must contain either K or E. Otherwise, no notifications are issued.

    For example, if you want to subscribe only list-related keyspace notifications, set notify-keyspace-events to Kl.

    The value AKE means all types of notifications are issued.