Oracle tech screen for principal MTS at OCI

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-11-19Added By Anonymous
Source: Link

Company: Oracle
Role: Principal Member of Technical Staff
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Design a thread-safe Redis inspired data structure that is accessed over the network and satisfies the following methods:
(Exact methods can vary to fit the conventions of the chosen programming language.)

The system must remain correct and performant under concurrent operations from multiple threads.

1. set(key: string, value: string): void
* Sets a key to a string value.
* Concurrent calls to set on different keys should proceed independently, but updates to the same key must be handled safely.

2. listPush(key: string, value: string): void
* If there is no value at key, this should create a new "list" containing the element value and store it at key.
* If there is an existing "list" located at key, push a string value onto the head of the "list".

3. get(key: string): Entry
* Gets the value of any type out of the data structure.
* Return an Entry object that abstracts over the possible return types.
* Should return null if no value is found for the key.
* Should allow multiple threads to read concurrently.

4. expire(key: string, time: integer): bool
* Expires a key (value returns as null) after time in seconds has elapsed from when expire was called on the key.
* Subsequent calls to expire should override previous calls.
* Calling with a negative time should cancel any previous expire call.
* Mutating a key assignment in any way should cancel any previous expire calls on that key.
* Keys should expire asynchronously so that reads and writes continue without delay.

"a": [1, 2]
setKey("a",[1])
setKey("a", 2)

Comments