Skip to main content
ubuntuask.com

Back to all posts

How to Create Custom Key-Space-Events on Redis?

Published on
4 min read
How to Create Custom Key-Space-Events on Redis? image

Best Redis Tools to Buy in December 2025

1 Redis in Action

Redis in Action

BUY & SAVE
$34.99
Redis in Action
2 Redi-Edge Dog Tag Knife Sharpener, Small

Redi-Edge Dog Tag Knife Sharpener, Small

  • MILITARY-GRADE BUILD ENSURES UNMATCHED DURABILITY IN TOUGH CONDITIONS.
  • RAZOR-SHARP PRECISION FOR A DURABLE EDGE EVERY SHARPENING.
  • PORTABLE AND LIGHTWEIGHT-PERFECT FOR SURVIVAL KITS AND ON-THE-GO USE.
BUY & SAVE
$21.17 $22.79
Save 7%
Redi-Edge Dog Tag Knife Sharpener, Small
3 Redi Shade No Tools Original Light Filtering Pleated Paper Shade White, 36" W x 72" L, 6 Pack

Redi Shade No Tools Original Light Filtering Pleated Paper Shade White, 36" W x 72" L, 6 Pack

  • ENJOY PRIVACY AND UV PROTECTION WITH OUR SOFT LIGHT-FILTERING SHADES.
  • CORDLESS DESIGN ENSURES SAFETY AND A SLEEK LOOK IN ANY SPACE.
  • EASY NO-TOOLS INSTALLATION FOR ANY HOME, RV, OR DORM SETUP.
BUY & SAVE
$24.98
Redi Shade No Tools Original Light Filtering Pleated Paper Shade White, 36" W x 72" L, 6 Pack
4 Redi Shade No Tools Original Blackout Pleated Paper Shade Black, 36" W x 72" L, 6 Pack

Redi Shade No Tools Original Blackout Pleated Paper Shade Black, 36" W x 72" L, 6 Pack

  • BLOCK 99% LIGHT FOR ULTIMATE PRIVACY AND UV PROTECTION.
  • CORDLESS DESIGN ENSURES SAFETY AND A SLEEK APPEARANCE.
  • DURABLE PAPER WITHSTANDS SUNLIGHT; EASY NO-TOOLS INSTALLATION!
BUY & SAVE
$29.97
Redi Shade No Tools Original Blackout Pleated Paper Shade Black, 36" W x 72" L, 6 Pack
5 Redi-Edge Tactical Knife Sharpener - Military-Grade Pocket knife Sharpener with Duromite Sharpening Elements - Honing Rod with 40° Double Edge for Kitchen & Hunting - Compact Travel Knife Honing Rod

Redi-Edge Tactical Knife Sharpener - Military-Grade Pocket knife Sharpener with Duromite Sharpening Elements - Honing Rod with 40° Double Edge for Kitchen & Hunting - Compact Travel Knife Honing Rod

  • PERFECT 40° EDGE: CREATES A CONSISTENT, SHARP EDGE FOR ALL KNIVES.

  • ERGONOMIC GRIP: COMFORTABLE AND SECURE, ENSURING SAFE SHARPENING RESULTS.

  • PORTABLE DESIGN: LIGHTWEIGHT AND COMPACT FOR TRAVEL AND OUTDOOR USE.

BUY & SAVE
$18.32
Redi-Edge Tactical Knife Sharpener - Military-Grade Pocket knife Sharpener with Duromite Sharpening Elements - Honing Rod with 40° Double Edge for Kitchen & Hunting - Compact Travel Knife Honing Rod
6 Redi-Edge Portable Knife Sharpener - Red Pocket knife Sharpener with Duromite Sharpening Elements - Honing Rod with 20° Double Edge for Kitchen, Home & Hunting - Compact Travel Knife Honing Rod

Redi-Edge Portable Knife Sharpener - Red Pocket knife Sharpener with Duromite Sharpening Elements - Honing Rod with 20° Double Edge for Kitchen, Home & Hunting - Compact Travel Knife Honing Rod

  • PERFECT 20° EDGE: ACHIEVE CONSISTENT SHARPNESS FOR ALL BLADES.
  • DURABLE BUILD: TOUGH STAINLESS STEEL ENSURES LONG-LASTING PERFORMANCE.
  • PORTABLE & LIGHTWEIGHT: IDEAL FOR HIKERS AND TRAVELERS, SHARPENS ANYWHERE!
BUY & SAVE
$26.51
Redi-Edge Portable Knife Sharpener - Red Pocket knife Sharpener with Duromite Sharpening Elements - Honing Rod with 20° Double Edge for Kitchen, Home & Hunting - Compact Travel Knife Honing Rod
7 ACTINTOOL Mastic Glue Removing Redi Lock Tungsten Scraper for Husqvarna Floor Grinder (Redi Lock) (Pack of 3 pcs)

ACTINTOOL Mastic Glue Removing Redi Lock Tungsten Scraper for Husqvarna Floor Grinder (Redi Lock) (Pack of 3 pcs)

  • AGGRESSIVE REMOVAL OF TOUGH ADHESIVES, NO GUMMING UP!
  • COMPATIBLE WITH HUSQVARNA GRINDERS FOR SEAMLESS USE.
  • PACK OF 3 WITH REPLACEABLE 4-SIDED CARBIDE INSERTS!
BUY & SAVE
$125.00
ACTINTOOL Mastic Glue Removing Redi Lock Tungsten Scraper for Husqvarna Floor Grinder (Redi Lock) (Pack of 3 pcs)
+
ONE MORE?

To create custom key-space-events on Redis, you can use the CONFIG SET command to define the types of events you want to listen for. Key-space events allow you to receive notifications when specific types of Redis commands are executed on specific keys.

To set up key-space events, you will first need to configure Redis to broadcast events by setting the notify-keyspace-events configuration parameter. You can specify which events to listen for by using different characters to represent different types of events.

For example, to listen for all key-related events (e.g. set, del, expire), you can set the notify-keyspace-events parameter to the value AKE, which stands for All key events. You can also specify more granular events by using additional characters such as g for generic commands, E for key events related to list operations, and so on.

After configuring the key-space events, you can use the PSUBSCRIBE command to subscribe to specific types of events. When an event occurs that matches the specified pattern, Redis will publish a message to the client, allowing you to take the necessary actions based on the event.

By creating custom key-space events on Redis, you can monitor and react to changes in specific keys, allowing you to build more sophisticated and responsive applications that leverage the power of Redis as a data store.

What is the significance of key-space-events in redis?

In Redis, key-space-events refer to notifications that are triggered whenever a key is created, modified, or deleted in the database. These events are significant because they allow applications to react to changes in the database in real-time.

Key-space-events can be used to implement features such as cache invalidation, real-time notifications, and data synchronization between different parts of an application. By subscribing to key-space-events, developers can build more responsive and efficient applications that react immediately to changes in the database.

Overall, key-space-events in Redis provide a powerful way to build real-time applications and improve the overall performance and responsiveness of the system.

What is the difference between key-space-events and pub/sub mechanisms in redis?

Key-space-events and pub/sub mechanisms in Redis are both mechanisms used for handling events and notifications in Redis, but they have some key differences:

  1. Key-Space-Events:
  • Key-space-events allow clients to subscribe to notifications based on specific key-space events in Redis.
  • Clients can be notified when certain types of commands are executed on keys in the database, such as set, delete, expire, and more.
  • Key-space-events are more focused on specific key operations and are useful for monitoring changes to specific keys in the database.
  1. Pub/Sub Mechanisms:
  • Pub/Sub mechanisms in Redis allow clients to subscribe to channels and receive messages published to those channels by other clients.
  • Pub/Sub mechanisms are more generalized and allow for broader message distribution between clients.
  • Pub/Sub mechanisms are not tied to specific key operations, but rather allow for clients to publish and subscribe to messages on any channels they are interested in.

In summary, key-space-events are more focused on specific key operations and monitoring changes to specific keys, while pub/sub mechanisms are more generalized and allow for broader message distribution between clients.

How to set up key-space-events in redis configuration?

To set up key-space-events in your Redis configuration, follow these steps:

  1. Open the Redis configuration file (redis.conf) in a text editor.
  2. Search for the "notify-keyspace-events" parameter in the file. This parameter controls which Redis events trigger the publication of messages to channels for Pub/Sub support.
  3. By default, the "notify-keyspace-events" parameter is set to an empty value, which means key-space-events notifications are disabled.
  4. To enable key-space-events notifications, set the "notify-keyspace-events" parameter to one or more of the following values, depending on the type of events you want to be notified about: K: Key-space events, such as key expired, evicted, or deleted. E: Key-event events, such as key events related to streams. g: Generic commands (non-type specific) events.
  5. Save the Redis configuration file after making the necessary changes.
  6. Restart the Redis server to apply the new configuration.
  7. You can now subscribe to specific channels to receive notifications about key-space events and key-event events in Redis. For example, you can use the PUBLISH and SUBSCRIBE commands in Redis CLI to publish and subscribe to channels for those events, respectively.

By following these steps, you can set up key-space-events in Redis and start receiving notifications about specific key-related events in your Redis database.