What is Neural Network?

Neural Network is set of algorithm which follows the working of human brain.
It has dense cells called neurons which are helpful for system to learn things. For neural network we need at least 3 layers, Input layer, hidden layer and output layer. …

What is EMQX??

EMQ X (Erlang/Enterprise/Elastic MQTT Broker) is open source IoT MQTT message broker. It is based on Erlang/OTP. MQTT is a lightweight message exchange protocol using publish-subscribe pattern. EMQX support TCP / SSL connection support.

What is RabbitMQ??

RabbitMQ is a message broker or queue manager or we…

We can get notification when the key expires in redis. This feature can be implemented by Redis Keyspace notification. For this we have to set configuration (notify-keyspace-events “KEx”) in the redis.conf file.

K for keyspace events, E for keyevent events and x for expire. This configuration informs us when any key is expired.

Set configuration from redis-cli — config set notify-keyspace-events KEx


Set configuration from redis.conf file — notify-keyspace-events “KEx”

Python Code to get notification of expired keys-

#importing redis
import redis
#connecting redis
redis_connection = redis.StrictRedis(host='localhost', port=6379, db=0)
#publish of redis events
redis_subscriber = redis_connection.pubsub()
subscribe event for all keys. * means all the keys, if we want any specific key we have to give #that key name.
#listening message or notification of redis event.
for msg in redis_subscriber.listen():

We all are using python logging module but sometimes it complicated to identify the particular log. So, I am going to explain another python module which is quite interesting to use in your code. That module name is “logzero”

logging vs logzero

Logging is used by every python developer. The sample uses of logging module is given below.

import logging
logging.warning(‘Warning message from your code.’)
logging.error(‘Error message from your code.’)
logging.critical(‘Critical message from your code.’)

The working of logging and logzero is same but logzero is Pretty formatting, including level-specific colors in the console. For logzero first you have to install logzero module via pip3 install logzero. The sample uses of logzero module is given below.

from logzero import logger
logger.debug(“Debug message from your code.”)
logger.info(“Info message from your code.”)
logger.warning(“Warning message from your code.”)
logger.error(“Error message from your code.”)

Vaibhav Mishra

I am passionate software developer working in different technologies like Python, ML, Django and JavaScript.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store