Yasar Whizz
Yasar Whizz

Reputation: 17

Implement own in memory cache mechanism in spring boot

I was asked to implement an in memory cache mechanism in my spring boot application. My application is related to social media. User can register and login User can add friend User can post status with privacy criteria public and private User can view public post and private post of their friend post only User can see the post which has more number of likes and they have access to.

How can I implement my own cache mechanism? I should design my own data structure to store cache.

Which api end points can I have cache features?

I'm new to spring.

Thanks in advance

Upvotes: -1

Views: 1669

Answers (2)

Yasar Whizz
Yasar Whizz

Reputation: 17

I done it by creating concurrent hashmap and stored value in runtime and also made that hashmap object Threadsafe. which means only one thread can edit the value of hashmap

Upvotes: 0

João Dias
João Dias

Reputation: 17500

Why not use Caffeine, which is an already built and tested in-memory cache for Java applications? You can find more information at:

It is pretty simple to configure and use. You will save yourself hours of development.

Upvotes: 1

Related Questions