Redis Flashcards

1
Q

What is Redis?

A

Distributed key-value store

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Types allowed

A

Values are types:
* List of strings (with insertion on head or tail)
* Set of strings
* Sorted set of strings
* Hashes (similar to a struct/map)
* Bit array
* HyperLogLogs (probabilistic data structure for estimating the
number of elements in a set)
Each data type has a set of operations it supports.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can redis be used as?

A

Redis can be used as a database, a cache or a message broker.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Characteristics of redis when used in cache

A

it uses a limited amount of memory;
* it uses a LRU algorithm for cache eviction. Possible to control
cache eviction by:
* Set a TTL for eviction;
* Define that only keys with a TTL can be evicted (making some
entries persistent).
Redis supports transactions including a sequence of operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Redis Architecture

A

Each server maintains key-value pairs.
Each server executes operations in the values.
Possible to create a cluster of Redis servers, with data
partitioned.
Primary-backup (remember Dist. Sys. course), with
asynchronous replication.
Multi-master replication with automatic conflict-resolution
(based on CRDTs).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Partitioning strategies

A
  • Range partitioning;
  • Hashing (some clients implement consistent hashing).
  • Tag hashing to control location of data – a tag is a prefix to the
    key; only the tag is hashed.
  • E.g. {CSS}key1 and {CSS}key2 are hashed to the same server, as
    only CSS is hashed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Replication is usually used in Redis

A

No, but it has support for it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Persistence (3)

A

Several alternatives:
* No persistence.
* RDB persistence: performs point-in-time snapshots of the
database state at specified intervals.
* Append-only fashion: logs every write operation received by
the server, that will be played again at server startup. Log
compressed in background.
* Durability depends on the parameters used for fsync. Remember
the OS course.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Uses

A

Simple caching (as with Memcached).
Advanced caching functionalities, using data types support.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to guarantee that the cache is up-to-date with
the database.

A

With CosmosDB and Redis, a possible solution is to use the
timestamp associated with the document to guarantee that the
latest version is kept in the cache. The value set should include
both the key and the timestamp. When setting the value of the
cache, the old value can be returned, allowing the client to
check if it has overwritten a more recent value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly