Simple Persistent Store for Increment/Decrement Operations?

I'm looking for something that will allow me to have a store that is persisted on-disk, probably fully loaded into memory, and allows me to store key-value pairs where the value is an integer that can be atomically incremented and decremented or else compare-and-swapped.

I'm not finding anything immediately, does anybody have any suggestions?

1 Like

All transactional databases support storing integers that can be atomically incremented and decremented. Transactions are made for this.

Sqlite is a good default choice for an in-process database. Any of the key-value stores with transactions would also work, e.g., RocksDb.

3 Likes

Ah, yeah, I just realized that write transactions in redb block, so that would make it safe to manually increment a value during the transaction. Since the Iroh crate I'm using also uses redb, that's probably my best option.

1 Like

native_db also builds on top of redb; any thoughts here @vincent-herlemont?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.