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!
缓存可能是提升应用性能最常见的做法和技术,Elixir有许多缓存技术,其中一些非常棒。但是它们许多值关注本地缓存,但是我们面对的情况是,今时今日,我们极少只在单机部署应用,尤其是在 Elixir/Erlang 的世界。大多数情况我们都将处理分布式系统,即至少包含两个节点。也就是说,一个本地缓存不够,我们还需要一个分布式缓存,不仅为我们提供优异的性能,还有线性的横向扩展性,当然,还有能从集群的任何节点获取数据。你可能会想,为何没有一个库能同时实现两者,根据需求创建不同的缓存拓扑,它可以是一个简单的本地缓存,一个分布式的分割的缓存,或者一个就近缓存拓扑。哈哈,这就是Nebulex!
Nebulex 是为 Elixir 打造的分布式缓存框架,它的API和Ecto很像,借鉴了其简单的接口、灵活性和可插拔的架构。
Nebulex有三个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/