anitsh / til

Today I Learn (til) - Github `Issues` used as daily learning management system for taking notes and storing resource links.
https://anitshrestha.com.np
MIT License
77 stars 11 forks source link

In-Memory Database - Redis, Memcached #522

Open anitsh opened 3 years ago

anitsh commented 3 years ago

Keeps data in the memory!

Basic Features

anitsh commented 3 years ago

Redis - Remote Dictionary Server

An in-memory key-value data store for use as a database, cache, message broker, and queue.

All Redis data resides in-memory, in contrast to databases that store data on disk or SSDs. By eliminating the need to access disks, in-memory data stores such as Redis avoid seek time delays and can access data in microseconds. Redis features versatile data structures, high availability, geospatial, Lua scripting, transactions, on-disk persistence, and cluster support making it simpler to build real-time internet scale apps. It works with relational or key-value databases to improve performance, such as MySQL, Postgres, Aurora, Oracle, SQL Server, DynamoDB, and more.

Unlike simplistic key-value data stores that offer limited data structures, Redis has a vast variety of data structures:

Use Cases: Caching, Chat, messaging, and queues, Gaming leaderboards, Session store, Rich media streaming, Geospatial, Machine Learning, Real-time analytics

Language: Python, Java, PHP, C/C#/C++, Perl, Go, Ruby, JavaScript, Node.js

Comparison to other databases

Name Type Data storage options Query types Additional features
Redis In-memory non-relational database Strings, lists, sets, hashes, sorted sets Commands for each data type for common access patterns, with bulk operations, and partial transaction support Publish/Subscribe, master/slave replication, disk persistence, scripting (stored procedures)
memcached In-memory key-value cache Mapping of keys to values Commands for create, read, update, delete, and a few others Multithreaded server for additional performance
MySQL Relational database Databases of tables of rows, views over tables, spatial and third-party extensions SELECT, INSERT, UPDATE, DELETE, functions, stored procedures ACID compliant (with InnoDB), master/slave and master/master replication
PostgreSQL Relational database Databases of tables of rows, views over tables, spatial and third-party extensions, customizable types SELECT, INSERT, UPDATE, DELETE, built-in functions, custom stored procedures ACID compliant, master/slave replication, multi-master replication (third party)
MongoDB On-disk non-relational document store Databases of tables of schema-less BSON documents Commands for create, read, update, delete, conditional queries, and more Supports map-reduce operations, master/slave replication, sharding, spatial indexes

Resource

anitsh commented 3 years ago

Memcached

Memcached has simpler use cases as it has fewer features. Primarily used for cache and session storage.

Language/Protocol Support: Python, Java, PHP, C/C#/C++, Perl, Go, Ruby, JavaScript, Node.js, ASCII protocol, Binary protocol, TCP & UDP protocols

Resource

anitsh commented 3 years ago

Difference

Feature Memcached Redis
Sub-millisecond latency Yes Yes
Developer ease of use Yes Yes
Data partitioning Yes Yes
Support for a broad set of programming languages Yes Yes
Advanced data structures - Yes
Multithreaded architecture Yes -
Snapshots - Yes
Replication - Yes
Transactions - Yes
Pub/Sub - Yes
Lua scripting - Yes
Geospatial support - Yes