Redis is an open source, high speed, key-value NoSQL datastore. It can be used to provide solution for the below mentioned use cases – NoSQL databas

Redis Cache With Spring Boot

submited by
Style Pass
2020-09-20 09:52:00

Redis is an open source, high speed, key-value NoSQL datastore. It can be used to provide solution for the below mentioned use cases –

NoSQL databases (aka “not only SQL”) are non tabular, and store data differently than relational SQL databases. NoSQL databases come in a variety of types based on their data model.

A cache is a reserved storage location that collects temporary data to help websites, browsers and apps load faster. A cache makes it easy to quickly retrieve data, which in turn helps devices run faster. It acts like a memory bank, making it easy to access data locally instead of redownloading it every time you visit a website or open an app.

Redis is an in-memory database because it keeps the whole data set in memory, and answers all queries from memory. Because RAM is faster than disks, this means Redis always has very fast reads. The drawback is that the maximum size of the data set is limited by the available RAM. Redis has various options to save the data to permanent storage. This permanent representation can then be used to rebuild the in-memory state of a Redis instance. However, this representation is not indexed and cannot be used to answer queries directly from disk. Lets discuss about two of the most common use cases of in-memory cache –

@EnableCaching It is a class-level annotation. We can enable caching in the Spring Boot application by using the annotation @EnableCaching. It is used together with @Configuration class. The auto-configuration enables caching and setup a CacheManager, if there is no already defined instance of CacheManager. It scans for a specific provider, and when it does not find, it creates an in-memory cache using ConcurrentHashMap.

Leave a Comment