Redis: Cache, sessions and queues

Contents
Introduction
Three Redis jobs
Persistence without illusion
Teams every day
Cluster and Sentinel

Introduction

Redis are data structures in memory with network access: strings, Hashes, lists, lots. Reading in fractions of a millisecond makes it standard cache SQL base.

Three Redis jobs

Cash: Add the results of heavy queries to TTL and don’t think. Sessions: shared session storage for multiple backends instead Sticky sessions. queues and meters: atomic INCR and Blocking readings from lists close limits and background tasks broker.

Persistence without illusion

By default Redis in memory: the process fell – the data evaporated. RDB Takes periodic pictures (you can lose minutes), AOF writes each operation (slower, but whole seconds). There's enough RDB for the cache. Include AOF sessions and queues, otherwise the first restart will be incident.

Teams every day

Base of the day: SET/GET with TTL via SETEX, INCR for meters, LPUSH/BRPOP For queues, SADD/SMEMBERS for sets, HSET/HGETALL for hashes. Name the keys with the namespace through the colon ?app:session:123- otherwise, in six months, no one He won't remember what's next to him.

Cluster and Sentinel

One instance rests on the memory and becomes a single point of failure. Sentinel gives an automatic filer between the master and the replicas. The cluster shuffles data by nodes. Start with one instance and Sentinel, the cluster connect according to the measured need, not "on" growth.

Related articles
Databases
Redis
NoSQL databases
MongoDB

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: