Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between In-Memory cache and In-Memory Database

Tags:

I was wondering if I could get an explanation between the differences between In-Memory cache(redis, memcached), In-Memory data grids (gemfire) and In-Memory database (VoltDB). I'm having a hard time distinguishing the key characteristics between the 3.

like image 939
Yolo49 Avatar asked May 03 '16 23:05

Yolo49


People also ask

What is difference between cache and database?

Databases are generally regarded as persistent, consistent and queryable data stores. Caches behave like databases, except they shed many features to improve performance like it favors fast access over durability & consistency.

Is cache an in-memory database?

What is an In-Memory Cache? An in-memory cache is a data storage layer that sits between applications and databases to deliver responses with high speeds by storing data from earlier requests or copied directly from databases.

What is difference between memory and database?

An in-memory database keeps all data in the main memory or RAM of a computer. A traditional database retrieves data from disk drives. In-memory databases are faster than traditional databases because they require fewer CPU instructions. They also eliminate the time it takes to access data from a disk.

What is the difference between cache and memory?

In this article, we're going to break down the differences between cache and cache memory. Basically, a cache stores temporary data and can be found on computers, phones, apps and web browsers. Cache memory also stores temporary data but is a physical computer component.


2 Answers

Cache - By definition means it is stored in memory. Any data stored in memory (RAM) for faster access is called cache. Examples: Ehcache, Memcache Typically you put an object in cache with String as Key and access the cache using the Key. It is very straight forward. It depends on the application when to access the cahce vs database and no complex processing happens in the Cache. If the cache spans multiple machines, then it is called distributed cache. For example, Netflix uses EVCAche which is built on top of Memcache to store the users movie recommendations that you see on the home screen.

In Memory Database - It has all the features of a Cache plus come processing/querying capabilities. Redis falls under this category. Redis supports multiple data structures and you can query the data in the Redis ( examples like get last 10 accessed items, get the most used item etc). It can span multiple machine and is usually very high performant and also support persistence to disk if needed. For example, Twitter uses Redis database to store the timeline information.

like image 176
VimalKumar Avatar answered Oct 02 '22 02:10

VimalKumar


I don't know about gemfire and VoltDB, but even memcached and redis are very different. Memcached is really simple caching, a place to store variables in a very uncomplex fashion, and then retrieve them so you don't have to go to a file or database lookup every time you need that data. The types of variable are very simple. Redis on the other hand is actually an in memory database, with a very interesting selection of data types. It has a wonderful data type for doing sorted lists, which works great for applications such as leader boards. You add your new record to the data, and it gets sorted automagically.

So I wouldn't get too hung up on the categories. You really need to examine each tool differently to see what it can do for you, and the application you're building. It's kind of like trying to draw comparisons on nosql databases - they are all very different, and do different things well.

like image 35
CargoMeister Avatar answered Oct 02 '22 01:10

CargoMeister