pars
pars

Reputation: 439

How Redis store key-value?

I am studying Redis, and I wonder how Redis stores key-value that make time complexity of GET and SET is O(1). Is this hash table? Btw, how fast Redis is when storing data in RAM instead of storing data on disk.

Upvotes: 1

Views: 1197

Answers (1)

vmr
vmr

Reputation: 1935

Redis is a in-memory key/value store i.e a HashMap/Hashtable kind of datastructure. And the time complexity of GET or SET for a HashMap is O(1). Redis tends to store data on RAM and persist it on to disk as well. But persistence to disk is a background journaling job. Since read/write operations to RAM are blazing fast, it is often used for caching.

Upvotes: 2

Related Questions