tidwall / buntdb

BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support
MIT License
4.57k stars 289 forks source link

Save index operations #52

Closed apple314159 closed 4 years ago

apple314159 commented 5 years ago

THE AOF saves the set and del operations. However, the index creation operations are not saved. When a program restarts it's hard to reproduce the previous indexes.

tidwall commented 4 years ago

Unfortunately, indexes cannot be automatically saved with the AOF file.

This is because the index functions take in less functions that are programmatically defined, and there's no way to dynamically serialize those operations.

If your indexes are very simple (like a gjson path or binary comparisons) then it should be possible to serialize a custom entry in the buntdb database that defines your indexes.

Then when you open your database, you can load from the database, deserialize, and execute the index operations.