A quebra das startups

O Silicon Valley Bank (Banco do Vale do Silício, em livre tradução) é um banco conhecido por fornecer capital para startups. O banco pode ser pouco conhecido, mas, de acordo com a CNN, estava entre…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Working with Redis Keyspace Notifications x Python

As we know redis is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. since version 2.8.0, Redis provides a mechanism for client code to subscribe to a Pub/Sub channel that monitors events related to data in real time. it’s called keyspace notification

Keyspace notifications allow clients to subscribe to two channels in order to receive events affecting the Redis data set in some way. Examples of the events that are possible to receive are the following:

By default, keyspace events notifications are disabled. We can enable them in redis.conf or redis-cli as below

Setting the parameter to the empty string disables notifications. In order to enable the feature a non-empty string is used, composed of multiple characters, where every character has a special meaning according to the following table:

Then, let’s check we can subscribe for a pattern by using PSUBSCRIBE redis command

First let’s install Redis package

Listener

Publisher

Now let’s run python file

after 10 second (expTime), your message will’be processed, and In the redis server terminal you will see your key has been sent:

Congratulations, your event with redis keyspace notification is ready !

Add a comment

Related posts:

Top contenders for PFA player of the year

With the English Premier League drawing to a close, it would be interesting to see which player bags the PFA Player of the Year award. The award is widely regarded as the top individual recognition…

Learning a New Language This New Year

Learning a language can be difficult at times since you have to make sure you are continually practicing. The best method to improve is consistent practice. There are many ways to continue learning a…

More Technology to Counteract the Labor Shortage

I grew up in a builder’s house. My father was a home builder during most of his lifetime. From seeing him and the things he did, I decided to become an architect. I remember how often my father had…