Giter Site home page Giter Site logo

ets_helper's Introduction

EtsHelper

hex.pm hexdocs.pm Build Status

EtsHelper is a wrapper of ETS. It does not try to wrap all the functionality, only those functions that are constantly used in Elixir projects. It also includes some new functions. This is a library that could be improved in the future if it is required by new needs.

Installation

Add ets_helper to your list of dependencies in mix.exs:

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

How to use it

  • New table
iex> EtsHelper.init_table(:my_table)
  • New table with options
iex> EtsHelper.init_table(:my_table, [:named_table, :public, {:read_concurrency, true}, {:write_concurrency, true}])
  • Insert data
iex> EtsHelper.insert(:my_table, {"key", "data"})
iex> EtsHelper.insert(:my_table, {:key, :data})
iex> EtsHelper.insert(:my_table, {{:key, 2}, {1, 2, 3}})
  • Get data
iex> EtsHelper.get(:my_table, "key")
  • Get all data
iex> EtsHelper.all(:my_table)
  • Get all keys
iex> EtsHelper.keys(:my_table)
  • Delete data
iex> EtsHelper.delete(:my_table, "key")
  • Delete all data
iex> EtsHelper.delete_all(:my_table)
  • Delete all registers whose data matches with the given function
iex> # Delete odd data
iex> EtsHelper.delete_data_with(:my_table, fn x -> rem(x, 2) != 0 end)
  • Get data according to given pattern
iex> EtsHelper.insert(table_name, [{:brunte, :horse, 5}, {:ludde, :dog, 5}, {:rufsen, :dog, 7}])
iex> EtsHelper.match(table_name, {:"_", :dog, :"$1"})
  • Table Information
iex> EtsHelper.info(:my_table)

Test

Run the tests.

$> mix test 

ets_helper's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gogohhh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.