sheharyarn / memento

Simple + Powerful interface to the Mnesia Distributed Database 💾
http://hexdocs.pm/memento/
MIT License
734 stars 23 forks source link

Does memento support disc_only as well as disc_copies? #11

Closed carloslahrssen closed 5 years ago

carloslahrssen commented 5 years ago

Hello, According to mnesia documentation. Mnesia has the ability to support, ram, disc_only as well as disc_copies.

ram_copies

This option makes it so all data is stored exclusively in ETS, so memory only. Memory should be limited to a theoretical 4GB (and practically around 3GB) for virtual machines compiled on 32 bits, but this limit is pushed further away on 64 bits virtual machines, assuming there is more than 4GB of memory available.

disc_only_copies

This option means that the data is stored only in DETS. Disc only, and as such the storage is limited to DETS' 2GB limit.

disc_copies

This option means that the data is stored both in ETS and on disk, so both memory and the hard disk. disc_copies tables are not limited by DETS limits, as Mnesia uses a complex system of transaction logs and checkpoints that allow to create a disk-based backup of the table in memory.

Learn You Some Erlang for Mnesia I was wondering if Memento had the same support. I'm referencing this section of the mnesia documentation. Thank you!

sheharyarn commented 5 years ago

Hey @carloslahrssen. Yes, it does. Memento is a wrapper around Mnesia and supports almost all options including ram_copies, disc_copies and disc_only_copies.

You have to pass these options when creating the table. Refer to the example in Memento.Schema docs and also take a look at Memento.Table.create/2.

# Create RAM copies
# Equivalent to calling: Memento.Table.create(YourTable, ram_copies: [node()])
Memento.Table.create(YourTable)

# Create Disc copies (after you've created the schema)
Memento.Table.create(YourTable, disc_copies: [node()])

# Create Disc only copies (also after you've created the schema)
Memento.Table.create(YourTable, disc_only_copies: [node()])