For example, incrementing the view count of a post on blind would be a good use case of redis or bitcask according to DDIA
It’s a good optimization but you’re still gonna need persistent storage
Thanks. I guess bitcask does persist data but redis only does so periodically depending on your configuration? Have not used in-memory db before
It’s worth considering why Redis is good but not enough in this case. If you use only in-memory storage, an outage would wipe out your data. It’s a non-starter really. If you use only disk storage, it’ll likely be too slow for something as write-heavy as a view counter. You’ll probably run into data contention. Using redis with periodic persistent writes means less writing to disk while still having fast read/writes to memory. And when your in-memory redis db goes bust, you still have a “backup” on disk
This is an in-memory cache not a DB. The increment will occur on server side cache then write through to a persistent store.
Are you talking about what eBay suggested above- using some concurrent friendly data type as the counter then periodically updating db? Or are you talking about bitcask and redis
i dont understand the use of atomic integer. That would just save the result to the JVM memory space right? If you want to retrieve post_count from another service wouldnt it be better to use an in-memory cache separate from your application? Sorry if i dont understand the questino
AtomicInteger
How atomic integer is going to work if application has more than one instance?
AtomicInteger then periodically update the value in regular database without need for separate in-memory db?