mudasobwa

mudasobwa

Creator of Cure

The very simple :ets wrapper simplifying cross-process :ets handling (like Agent, but :ets.)

NimbleETS is a very thin simple ETS wrapper, simplifying the trivial usage of ETS as key-value store. It is not intended to replicate :ets module functionality by any mean. It might be used as a drop-in to avoid process-based Agent as key-value store. It exposes only CRUD functionality of ETS, alongside with Access behaviour.

defmodule MyApp.MyModuleBackedByTable do
  use NimbleETS
end
MyApp.MyModuleBackedByTable.ets_put(:foo, 42)
MyApp.MyModuleBackedByTable.ets_get(:foo)
#⇒ 42

MyApp.MyModuleBackedByTable.ets_del(:foo)
MyApp.MyModuleBackedByTable.ets_get(:foo, :bar)
#⇒ :bar

nimble_ets v0.1.0 — Documentation / GitHub - am-kantox/easy_ets: The very simple ETS wrapper simplifying cross-process ETS handling (like `Agent`, but `:ets`). · GitHub

Showing Posts 1 to 8

OvermindDL1

OvermindDL1

Hmm, Nimble* projects in the elixir ecosystem generally mean things that are the fastest possible implementation of something, how does this make ETS operations faster?

mudasobwa

mudasobwa OP

Creator of Cure

Yeah.

I had initially have called it NimbleAgent, then I realized it has nothing to do with Agent and I finally screwed the name totally up. It obviously does not make :ets any faster, but it also does not make it any slower, but the development process becomes faster.

OvermindDL1

OvermindDL1

Heh, following the pattern of Jose’s Nimble* libraries the development is often ‘slower’ than other libraries, but it ‘executes’ faster, it’s all a trade-off. ^.^

mudasobwa

mudasobwa OP

Creator of Cure

I’ll probably revoke the package during the weekend and re-deploy it as NimbleAgent as in was intentionally supposed. Nobody needs to know that there is :ets behind and it’s indeed notably faster than Agent on significant amount of CRUD operations.

OvermindDL1

OvermindDL1

It would indeed be a faster agent for setting/retrieving information, but that’s not what Agents are for. Agents are to do some processing of data on the agent state in another process so it doesn’t block your own process or for synchronization reasons (otherwise using ETS just for multi-process data storage with, say, the Eternal library for ease of use). If this uses ETS to do operations with no backing process then any functions called would need to be run in-process, thus blocking the existing process.

Like from the Agent docs itself:

    # Compute in the agent/server
    def get_something(agent) do                                                                                                                    
      Agent.get(agent, fn state -> do_something_expensive(state) end)                                                                              
    end                                                                                                                                            
                                                                                                                                                   
    # Compute in the agent/client                                                                                                                  
    def get_something(agent) do                                                                                                                    
      Agent.get(agent, & &1) |> do_something_expensive()                                                                                           
    end  

It uses this as an example of this, where the top does the expensive operation in the agent and the second does it in the caller, either of which can be preferred depending on what the purpose is, but if an ETS data store is used then I’m not sure how you could call operations on the Agent side without blocking your own process (like using Agent.cast/2,4). Agent’s aren’t just for holding data, you can use ETS for that, Agents are for running operations on that data in another process synchronously, and I don’t see how you could do that on a pure ETS table without a backing process?

josevalim

josevalim

Creator of Elixir

It is not really an agent though. It is the same API, but the operational semantics are very different. For example, agents should be supervised.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Maybe call it EasyEts ? I think that captures what you’re going for better than the Nimble prefix.

mudasobwa

mudasobwa OP

Creator of Cure

The package was renamed to EasyETS, thank you all.

The backing process is planned in 0.2.

My goal is to bring the operational semantics to be more or less the same as Agent has in the forthcoming updates. I posted the very alpha version to gather advises and thanks I received all I wanted.

Yes, thank you, I came to the exactly same name. All done.


FWIW, I retired NimbleETS at HexDocs.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews