- Make a key value store
- Make it persist
- (future) There may be some tasks that execute reminders (if a reminder flag with date is supplied).
- Probably initially persist to a file (maybe sqlite irl)
- The store shouldn't have to know that it's connected to a disk file
Read operations
- On open, read from file and hydrate in-memory map
OpenStore(filename string)
- If not there, it's a new store
- First, attempt to read from in-memory map
- If not there, read from file
- Else, return value from map
Write operations
- Need a persist to disk operation (Flush) (user shouldn't have to call it)
- When?
- Not when open or read
- Only
Set
can drift the in-memory db and file - Set always calls
Flush
, leaves the store always valid
Writing a test for OpenStore
- Asserting against values in a file
- Could just be
testdata.json
already on the fs
Hang on... we can use Flush for this!
Set Flush OpenStore from flushed file Get Assert
Can also write more granular individual tests after e2e ... (covers what we care about)
- How could users use this package?
- What's the simplest CLI around this store that would be of any use?