summaryrefslogtreecommitdiff
path: root/misc/key-value-store/README.md
blob: 98ac68154d3ecb4978ae1df46a4404ed393105c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Build a key value API that returns the time stamp of insertion when you insert a key.

1. Given the key only, return the value of the latest time stamp.
1. Given a key and time stamp return the value of the nearest time stamp in the past or equal for the key

* Maybe Hash Addressing with Chaining
* Time constantly increments
* Inserts happen in order so data can be stored in order
* This is sort of like commit log or event store/stream

```plaintext

key -> bucket

-----
|   | -> [ [timestamp, value], , , ]
-----
-----
|   |
-----
-----
|   |
-----
```

Because data is already sorted we can hash the key,
to find the correct bucket. Then perform a binary search
to find the value closest to the desired timestamp.