gravetii
gravetii

Reputation: 9634

From a server perspective, when should I excatly use Redis instead of a DS like HashMap or ConcurrentHashMaps

My keys consist of some non-primitive objects that need not necessarily require Redis, i.e. I do not necessarily intend to use Redis here as a any-DS-server. But assuming the server is up and running all the time, when should I consider using Redis as opposed to HashMaps to store relevant data? My problem statement would entail frequent write, read and removal from the chosen data structure.

Thanks!

Upvotes: 0

Views: 127

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533660

I am not an expert in Redis, and I have a similar product for Java, but to answer the question more generally....

Redis (and solutions like it) are useful for

  • sharing the data with other programs.
  • taking your data off heap, reducing your GC pauses.
  • giving you direct access to your data via tools.
  • replicating the data across machines.
  • fast restart of your Java application.
  • allowing you to split your Java application into multiple JVMs.

The downside is that you have to get everything through a TCP pipe which means higher latencies. If you can handle this, Redis may be very useful for some/most, though perhaps not all, your data structures.

What you might want is a data store which has the performance of being embedded and you wouldn't have the performance problem. ;)

Upvotes: 2

Related Questions