Redis
- Get link
- X
- Other Apps
What is the Redis cache?
Understanding Redis as a cache
Redis is designed around the concept of data structures and can store your dataset across Strings, Hashes, Sorted Sets, Sets, Lists, Streams, and other data structures or Redis modules.
// connecting redis client to local instance.const client = redis.createClient(6379)// Retrieving a string value from Redis if it already exists for this keyreturn client.get('myStringKey', (err, value) => { if (value) { console.log('The value associated with this key is: ' + value) } else { // key not found // Storing a simple string in the Redis store client.set('myStringKey', 'Redis Enterprise Tutorial'); }}); |
This snippet tries to retrieve the string value associated with the myStringKey key using the GET command. If the key is not found, the SET command stores the Redis Enterprise Tutorial value for myStringKey.
The same code can be written in Python, as shown here:
# Connecting redis client to local instance. r = redis.Redis(host = 'localhost', port = 6379, db = 0) # Retrieving a string value from Redis if it already existsfor this key value = r.get('myStringKey') if value == None: # key not found # Storing a simple string in the Redis store r.set('myStringKey', 'Redis Enterprise Tutorial') else :
This snippet tries to retrieve the string value associated with the myStringKey key using the GET command. If the key is not found, the SET command stores the Redis Enterprise Tutorial value for myStringKey.
The same code can be written in Python, as shown here:
# Connecting redis client to local instance. r = redis.Redis(host = 'localhost', port = 6379, db = 0) # Retrieving a string value from Redis if it already existsfor this key value = r.get('myStringKey') if value == None: # key not found # Storing a simple string in the Redis store r.set('myStringKey', 'Redis Enterprise Tutorial') else : |
Top Redis caching use cases
Front-end for DBMS
Legacy and traditional SQL databases were designed for functionality rather than speed at scale. A cache is often used to store copies of lookup tables and the replies to costly queries from the DBMS to reduce latency and significantly increase throughput. Enterprise caching solutions enable front-end DBMS to be always available and easily scale.
User session data
Caching user session data is an integral part of building scalable and responsive applications. Because every user interaction requires access to the session’s data, keeping that data in the cache speeds response time to the application user. Enterprise cache is used to handle the tremendous growth in user session data and the requirement to be available 24×7.
API responsiveness
Today’s modern applications use APIs to make requests for service from other components, whether inside (microservices architecture) or outside (SaaS) the application itself. Enterprise cache ensures these communications are always real-time to enable real-time application responses.
- Get link
- X
- Other Apps
Comments
Post a Comment