Read Story
Watch Main Stage Talk
Download Now
Ayush Singh

How to use Redis for cache management in bagisto

In this blog, we will see how to use Redis as cache management for bagisto.

Redis, which stands for Remote Dictionary Server, is a fast, open-source, in-memory key-value data store for use as a database, cache, message broker, and queue.

 

 

When the first time page is loaded, a database is queried on the server. Redis caches the query. Next time other user loads the page the results are provided from the redis without quering the actual database. It implements a persistent object cache (no expiration). An object cache works by caching the SQL queries in memory which are needed to load the web page. When the data of main database server is updated, then the corresponding key in the Redis is invalidated. So the it provides the updated data instead of caching the data. If a query is not available in Redis, the database provides the result and it adds the result to its cache.

For more info regarding Redis click here

Versions

Configuration

In this demo, we are using Redis on the same server, However it is recommended to use Redis on separate server for better performance.

Step1. Install Redis:-

 

Step2.  Install the predis/predis package via composer.

 

Step3. The Redis configuration for your application is located in the config/database file. Within this file, you will see a redis array containing the Redis servers utilized by your application. Now Add the cache block to the array like the following:

 

Step4. The cache configuration file for bagisto is located inside config/cache.php Now open this file and make the following changes:-

 

Step5. Now the final step, go to bagisto root,  edit the .env  file and make the following changes:-

and we are done here, Now it’s time to test whether redis is working as cache management for our bagisto or not.

The best and most simplest way to check  is by running;-

You will get all the insights of how and which database redis is using to storing the cache. Now to check whether redis database is storing the cache use the following commands as shown in the image below

 

Perfect!!! We have successfully integrated redis for cache management in bagisto.

In the next blog we will see how to use redis as session management for bagisto.

Also, for any suggestions or query contact us at https://bagisto.uvdesk.com/en/

Thanks for reading the article

Stay Connected !!

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php