Giter Site home page Giter Site logo

hpopp / nebulex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cabol/nebulex

0.0 2.0 0.0 121 KB

A fast, flexible and extensible distributed and local caching library for Elixir

Home Page: https://hexdocs.pm/nebulex

License: MIT License

Elixir 100.00%

nebulex's Introduction

Nebulex

A fast, flexible and powerful caching library for Elixir.

– Not only local but also distributed!

Build Status Coverage Status Inline docs

Features

See the getting started guide and the online documentation.

Installation

Add nebulex to your list dependencies in mix.exs:

def deps do
  [{:nebulex, "~> 1.0.0-rc.3"}]
end

Example

# In your config/config.exs file
config :my_app, MyApp.Cache,
  adapter: Nebulex.Adapters.Local,
  n_shards: 2,
  gc_interval: 3600

# In your application code
defmodule MyApp.Cache do
  use Nebulex.Cache, otp_app: :my_app
end

defmodule MyApp do
  use Application

  def start(_type, _args) do
    import Supervisor.Spec

    children = [
      supervisor(MyApp.Cache, [])
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

# Now it is ready to be used from any other module. Here is an example:
defmodule MyApp.Test do
  alias MyApp.Cache
  alias Nebulex.Object

  def test do
    Cache.set "foo", "bar", ttl: 2

    "bar" = Cache.get "foo"

    true = Cache.has_key? "foo"

    %Object{key: "foo", value: "bar"} = Cache.get "foo", return: :object

    :timer.sleep(2000)

    nil = Cache.get "foo"

    nil =
      "foo"
      |> Cache.set("bar", return: :key)
      |> Cache.delete(return: :key)
      |> Cache.get
  end
end

Important links

Testing

Testing by default spawns nodes internally for distributed tests. To run tests that do not require clustering, exclude the clustered tag:

$ mix test --exclude clustered

If you have issues running the clustered tests try running:

$ epmd -daemon

before running the tests.

Benchmarks

Simple and/or basic benchmarks were added using benchfella; to learn more, see the bench directory.

To run the benchmarks:

$ mix nebulex.bench

However, if you are interested to run more sophisticated load tests, perhaps you should take a look at the Nebulex Bench Project. This project allows you to run your own performance/load tests against Nebulex – additionally it also includes some load tests results.

Copyright and License

Copyright (c) 2017, Carlos Bolaños.

Nebulex source code is licensed under the MIT License.

nebulex's People

Contributors

cabol avatar ferigis avatar frekw avatar

Watchers

 avatar  avatar

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.