Sample questions
Question 1Easy
Which is a typical use of a key-value store such as Redis?
- Caching and session storage
- Complex joins across many tables
- Ad hoc SQL reporting
- Storing relationships with traversals
Answer: A. Caching and session storage
Explanation
Key-value stores give very fast get/set by key, ideal for caches and sessions.
Step-by-step solution
- Access pattern is by key.
Why the other options are wrong
- B. Key-value stores lack joins; complex joins need a relational database.
- C. Reporting suits SQL stores.
- D. Traversals suit graph stores.
Question 2Easy
Redis is primarily classified as a:
- Document store
- Key-value store
- Column-family store
- Graph database
Answer: B. Key-value store
Explanation
Redis maps keys to values held mainly in memory.
Step-by-step solution
- Redis stores data as a key mapped to a value.
- Its values can be strings, lists, sets, hashes and more, but the key is the access path.
- So Redis is primarily a key-value store, which is option B.
Why the other options are wrong
- A. A document store such as MongoDB is the document model, not Redis's main model.
- C. A column-family store such as Cassandra groups columns, which Redis does not do.
- D. A graph database such as Neo4j stores nodes and relationships.
Tip: Redis is an in-memory key-value store, often used for caching and sessions.
Question 3Easy
How are values normally retrieved from a key-value store?
- By a SQL JOIN
- By scanning every value for a match
- By looking up the key
- By traversing edges
Answer: C. By looking up the key
Explanation
Key-value stores offer fast access by exact key.
Step-by-step solution
- Key-value stores use keys to find values quickly.
- You look up the key to get the value directly.
- This is faster than scanning all values.
- Looking up the key is how values are retrieved normally.
- The correct answer is By looking up the key.
Why the other options are wrong
- A. SQL JOIN belongs to relational databases; key-value stores are not queried that way.
- B. Scanning every value is slow; key-value stores avoid it by going straight to the key.
- D. Traversing edges is a graph database operation, not how key-value stores fetch values.
Tip: Remember: Keys are used to directly access values in a key-value store.
Question 4Easy
Which is an in-memory key-value store commonly used for caching?
- Memcached
- Neo4j
- MongoDB GridFS
- HBase
Answer: A. Memcached
Explanation
Memcached stores key-value pairs in memory.
Step-by-step solution
- Cache = in-memory KV.
Why the other options are wrong
- B. Neo4j is a graph database, not an in-memory cache.
- C. GridFS stores large files, not in-memory key-value caching.
- D. HBase is a disk-based wide-column store, not a cache.
Question 5Medium
Why are key-value stores poorly suited to queries like 'find all users aged above 30'?
- They index only by key
- They cannot store numbers of any kind
- They forbid reading more than one key
- They have no persistence at all
Answer: A. They index only by key
Explanation
Without secondary indexes the only efficient access path is by key.
Step-by-step solution
- Key-value stores use keys to find values quickly.
- They do not support queries based on value ranges like age.
- Secondary indexes are needed for such queries, which they lack.
- So only key-based access is efficient in these stores.
- Final answer: They index only by key.
Why the other options are wrong
- B. Key-value stores can hold numbers; the problem is finding records by value, not storing them.
- C. Many key-value stores allow reading several keys in one call, so this is not the reason.
- D. Many key-value stores persist data to disk, so the lack of persistence is not the issue.
Tip: Remember: Key-value stores are best for exact key matches, not range or value-based queries.
Question 6Medium
Which Redis data type is best for a leaderboard with scores that must stay sorted?
- List
- Sorted set
- Set
- Hash
Answer: B. Sorted set
Explanation
Sorted sets keep members ordered by score and support rank queries.
Step-by-step solution
- Need ordering by score.
- ZADD / ZRANGE.
Why the other options are wrong
- A. List keeps insertion order.
- C. Sets are unordered and cannot keep scores sorted.
- D. Hash maps fields to values.
Question 7Medium
Which Redis data structure is a natural fit for a leaderboard ranked by score?
- Sorted set
- List
- Plain string
- Hash
Answer: A. Sorted set
Explanation
Sorted sets keep members ordered by score and support range queries by rank.
Step-by-step solution
- Sorted sets store elements with scores and ranks.
- They allow quick access to top or bottom ranked items.
- Range queries are efficient in sorted sets.
- Leaderboards need fast ranking and scoring operations.
- Sorted set matches leaderboard requirements perfectly.
Why the other options are wrong
- B. A list keeps order but does not hold scores for fast ranking by score.
- C. A plain string holds one value, so it cannot rank many members by score.
- D. A hash maps fields to values, which suits objects, not a score-ranked list.
Tip: Use sorted set for ranked data like leaderboards.
Question 8Medium
Which Redis commands implement a simple queue (FIFO) using a list?
- SET and GET on a string key
- INCR and DECR on a counter key
- LPUSH to add, RPOP to remove
- ZADD and ZREM on a sorted set
Answer: C. LPUSH to add, RPOP to remove
Explanation
Push at one end and pop at the other gives FIFO.
Step-by-step solution
- Opposite ends.
Why the other options are wrong
- A. SET and GET store a single string, not a FIFO list.
- B. INCR and DECR change a counter, not a queue.
- D. Sorted sets rank by score; they are not a plain FIFO list.
Question 9Hard
Which Redis command sets a key with an expiry of 60 seconds in one atomic call?
- SET key value TTL 60
- EXPIRE key 60 value
- SETEX key value 60
- SET key value EX 60
Answer: D. SET key value EX 60
Explanation
SET supports the EX option; SETEX takes the order key seconds value, so SETEX key value 60 is wrong.
Step-by-step solution
- SET key value EX 60 sets the value and its expiry in one atomic command.
- EX takes the expiry in seconds.
- So the answer is option D, SET key value EX 60.
Why the other options are wrong
- A. TTL is not a SET option; the word is EX or PX.
- B. EXPIRE sets a timeout on an existing key and does not take a value.
- C. SETEX takes the seconds before the value (SETEX key 60 value), so this argument order is wrong.
Tip: Use SET with EX for seconds or PX for milliseconds to set a value and expiry atomically.
Question 10Hard
Cassandra writes are fast mainly because they:
- Update rows in place on disk, seeking to the exact location of every row first
- Append to a commit log and memtable, then flush to immutable SSTables
- Lock the whole table for the duration of each write
- Require a read of the old row before each write
Answer: B. Append to a commit log and memtable, then flush to immutable SSTables
Explanation
Log-structured writes avoid random disk I/O.
Step-by-step solution
- Append to log.
- Memtable.
- Flush later.
Why the other options are wrong
- A. In-place updates are slow.
- C. Cassandra does not lock the whole table on each write.
- D. Writes do not read first.
Practise all 20 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →