Closed casey closed 3 months ago
No. compact() takes a &mut self
On Mon, Apr 1, 2024 at 12:55 AM Casey Rodarmor @.***> wrote:
I noticed that both fields of Database are Arcs, and was wondering if the Database could implement Clone, since it should be cheap, and since creating read and write transactions don't rely on borrowing the Database, it should be safe.
— Reply to this email directly, view it on GitHub https://github.com/cberner/redb/issues/789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGNXQHRPBFFYYDV4SMW6YLY3EHHVAVCNFSM6AAAAABFRHJOY6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYTONZVGUYTOOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Ahh, darn.
So can the database be shared throughout an app? If yes, then is it assumed we should wrap it in our own Arc?
Yes, ideally you can just pass &Database
around in your components as the methods to start transactions take &self
and Database
is Send + Sync
.
This could mean that you have to wrap it inside an Arc
, for example if the value is not part of a larger struct
and has its lifecycle determined by that.
I noticed that both fields of
Database
areArc
s, and was wondering if theDatabase
could implementClone
, since it should be cheap, and since creating read and write transactions don't rely on borrowing theDatabase
, it should be safe.