Caching might be one of the most common and used techniques to improve performance, and in Elixir there are different options available; some of them very good options. However, most of them are focused on local caching, but let’s face it, we seldom deploy our systems in a single node, it’s not a common scenario, specially in the Elixir/Erlang world, is it? Most of the cases we deal with distributed systems, which involves at least two nodes, therefore, sometimes a local cache might be not enough, for those cases we might also need a distributed cache, that give us not only good performance but also linear scalability, and of course, make data accessible from any node of the cluster. But you might be wondering, why not both? Why not a tool or library that give us the ability to create different caching topologies depending on our needs; it could be a simple local cache, a distributed or partitioned cache, or even a near cache topology. Well, this is where Nebulex comes in!
緩存可能是提升應(yīng)用性能最常見的做法和技術(shù),Elixir有許多緩存技術(shù),其中一些非常棒。但是它們?cè)S多值關(guān)注本地緩存,但是我們面對(duì)的情況是,今時(shí)今日,我們極少只在單機(jī)部署應(yīng)用,尤其是在 Elixir/Erlang 的世界。大多數(shù)情況我們都將處理分布式系統(tǒng),即至少包含兩個(gè)節(jié)點(diǎn)。也就是說,一個(gè)本地緩存不夠,我們還需要一個(gè)分布式緩存,不僅為我們提供優(yōu)異的性能,還有線性的橫向擴(kuò)展性,當(dāng)然,還有能從集群的任何節(jié)點(diǎn)獲取數(shù)據(jù)。你可能會(huì)想,為何沒有一個(gè)庫能同時(shí)實(shí)現(xiàn)兩者,根據(jù)需求創(chuàng)建不同的緩存拓?fù)洌梢允且粋€(gè)簡(jiǎn)單的本地緩存,一個(gè)分布式的分割的緩存,或者一個(gè)就近緩存拓?fù)洹9@就是Nebulex!
Nebulex 是為 Elixir 打造的分布式緩存框架,它的API和Ecto很像,借鑒了其簡(jiǎn)單的接口、靈活性和可插拔的架構(gòu)。
Nebulex有三個(gè)Adapter,分別是:
-
Nebulex.Adapters.Local
Local Generational Cache -
Nebulex.Adapters.Dist
Distributed Cache -
Nebulex.Adapters.Multilevel
Multilevel Cache
Nebulex is an open source caching library written in Elixir, highly inspired by Ecto, taking advantage of many of its benefits. Nebulex brings new powerful and useful features to the table, these are some of them:
- Simple and fluent API inspired by Ecto
- Flexible and pluggable architecture like Ecto – based on adapter pattern
- Built-in cache adaptersLocal generational Cache
- Distributed or Partitioned Cache
- Multi-level Cache
Support for different cache topologies – Partitioned, Near, etc.
- Time-based expiration
- Pre/post execution hooks
- Transactions (key-locking)
*Key versioning – optimistic offline locks
Optional statistics gathering
Besides, Nebulex is very well documented, so the idea is you start checking out the next links and confirm by yourself how that easy it is, and of course, all mentioned features above:
- Online Documentation
- Getting Started Guide
- Examples
- Partitioned Cache
- Near Cache
- Nebulex and Ecto Integration
- Ecto Fallback
- Using Nebulex from Erlang
Finally, if you find any bug or you have a suggestion, please feel free to open an issue, besides, don’t hesitate to send us pull requests in case you want to contribute :)
http://cabol.github.io/posts/2017/08/14/introducing-nebulex/