Persistence Implementation
Cache
This could be implemented with a combination of a memory limit and priority list (able to set priority to something like last accessed). But that requires something to watch access and estimate memory use.
Less clean, but easier is a weak map with uintptr.
Storage
I don't think sql does me much good. It handles indexing, but that's not a really hard problem. Some engines sort of handle NLP search, but the results are clumsy and inconsistent.
BoltDB is nice. There are some very interesting combinations of using many files and many sub-buckets.
I could also do an abstract key/value store so that I could use any of the no-sql servers.
mmap
A memory mapped file would really be cool. Could be one file per object, one file per object Type, some sort of file key (like User ID). The really tricky part here is that I would like to support slices and maps but I don't know how to map that to a memory mapped file.
Slices are not too bad because the mmap is backed by a slice. But it means append wouldn't work. Maps wouldn't work. I'd need to build a new set of data structures on top of an mmap.
Structs
I think structs will end up like this
type Task struct{
TaskKey
*FooIndex
*FooText
*FooData
}
type TaskKey []byte
type TaskIndex struct{
Done bool
Label LabelKey
Priority byte
}
type TaskText struct{
Title string
Notes string
}
type TaskData struct{
Points byte
}
Which is a little cumbersome, but not terrible. We may not need to break out the text indexing fields.