• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    Elixir
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PersistentEts

Ets table backed by a persistence file.

The table is persisted using the :ets.file2tab/2 and :ets.tab2file/3 functions.

Table is to be created with PersistentEts.new/3 in place of :ets.new/2. After that all functions from :ets can be used like with any other table, except :ets.give_away/3 and :ets.delete/1 - replacement functions are provided in this module. The :ets.setopts/2 function to change the heir is not supported - the heir setting is leveraged by the persistence mechanism.

Like with regular ets table, the table is destroyed once the owning process (the one that called PersistentEts.new/3) dies, but the table data is persisted so it will be re-read when table is opened again.

Example

pid = spawn(fn ->
  :foo = PersistentEts.new(:foo, "table.tab", [:named_table])
  :ets.insert(:foo, [a: 1])
end)
Process.exit(pid, :diediedie)
PersistentEts.new(:foo, "table.tab", [:named_table])
[a: 1] = :ets.tab2list(:foo)

Why not Dets?

With Dets every operation (read or write) hits the disk. For many application such a performance penalty (compared to ets) is not acceptable. Furthermore Dets tables are limited to 2GB. Dets doesn't support the ordered_set table type either.

With PersistentEts, the table remains in memory, so all read and write operations have the same performance they would have with pure Ets. Only periodically the table state is saved to a file. There's also no file limit, besides the memory and disk limitations. Since it's a regular Ets table, unlike with Dets, all types are fully supported.

Installation

The package can be installed by adding :persistent_ets to your list of dependencies in mix.exs:

def deps do
  [
    {:persistent_ets, "~> 0.1.0"}
  ]
end

Copyright and License

Copyright (c) 2017 Michał Muskała

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

jason

A blazing fast JSON parser and generator in pure Elixir.
Elixir
1,619
star
2

plug_attack

A plug building toolkit for blocking and throttling abusive requests
Elixir
419
star
3

decompile

Elixir
156
star
4

phoenix_etag

ETag support for phoenix
Elixir
43
star
5

env

Env is an improved application configuration reader for Elixir.
Elixir
30
star
6

plug_webhook

Simple tool for building plugs that handle wehbooks and verify signature.
Elixir
24
star
7

debounce

A process-based debouncer for Elixir
Elixir
23
star
8

format

A simple string formatter for Elixir
Elixir
17
star
9

xref.rs

Rust reimplementation of subset of Erlang's xref
Rust
15
star
10

horde

Persistent, distributed processes for Elixir
Elixir
8
star
11

fast_beam

Rust library for reading .beam files
Rust
8
star
12

hex_view_old

Elixir
7
star
13

time_format

Fast date/time formatting for elixir
Elixir
7
star
14

better_assert

Erlang
6
star
15

hex_view

Source explorer for hex packages
Elixir
5
star
16

simple_format

Rail's simple_format helper for Phoenix.HTML
Elixir
5
star
17

persist

GenStage-based persistence layer guaranteeing at-least-once delivery of the events.
Elixir
4
star
18

tic-tac-toe-workshop

Elixir
4
star
19

aoc-2020

Advent of code for 2020
Rust
3
star
20

exrb

Ruby-Elixir interoperability
Ruby
3
star
21

manager_supervisor

Elixir
3
star
22

superconsole

Enhancements to rails console based on pry
Ruby
2
star
23

llscm

Scheme to llvm compilter
Haskell
2
star
24

trace

Elixir
1
star
25

infiniq

Elixir
1
star
26

matasano

My solutions to the Matasano challenge in Elixir.
Elixir
1
star
27

file_count_optim

Benchmark for testing implementations of Enumerable.count/1 for File.Stream.
Elixir
1
star
28

dotfiles

Emacs Lisp
1
star
29

janusze

Ruby
1
star
30

jason_native

C++
1
star