Expander v0.0.1 Expander View Source
A library to expand/unshorten urls with unified cache store.
Synopsis
Expander aims to help you:
- Expand short urls
- Experiment with different key/value cache store backends for the shortened urls
- Allow end-users of your library liberty to choose their preferred backend
Status
| :thumbsup: | Continuous Integration | Test Coverage |
|---|---|---|
| Master | ||
| Development |
Cache Adapters
Expander supports the following cache adapters. Below is the list of the adapters currently included:
Provider | Expander adapter | Dependancy :—————| :———————————————-| :————— Local | Expander.Cache.Adapter.Local | Redis | Expander.Cache.Adapter.Redix | {:redix, “>= 0.0.0”} Memcache | Expander.Cache.Adapter.Memcache | {:memcachex, “>= 0.0.0”}
Getting Started
# In your config/config.exs file
config :sample, Sample.Expander,
adapter: Expander.Cache.Adapter.Local
# In your application code
defmodule Sample.Expander do
use Expander.Expand, otp_app: :sample
end
defmodule Sample.Url do
import Expander.Url
def generate(url) do
new
|> short_url(url)
end
end
# In an IEx session
Sample.Url.generate("http://stpz.co/haddafios") |> Sample.Expander.expand
Installation
Add expander to your list of dependencies in
mix.exs:def deps do [{:expander, "~> 0.0.1"}] end(Optional - only for Elixir < 1.4) Ensure expander is started before your application:
def application do [applications: [:expander]] end(Optional) If you are using
Expander.Cache.Adapter.RedixorExpander.Cache.Adapter.Memcache, you also need to add these dependencies to your deps and list of applications:# You only need to do this if you are using Elixir < 1.4 def application do [applications: [:expander, :redix]] end def deps do [{:expander, "~> 0.0.1"}, {:redix, ">= 0.0.0"}] end ## OR # You only need to do this if you are using Elixir < 1.4 def application do [applications: [:expander, :memcachex]] end def deps do [{:expander, "~> 0.0.1"}, {:memcachex, ">= 0.0.0"}] end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/expander.
Link to this section Summary
Types
An instruction to the Expander.Cache.Server to raise an error in the client
Keys allowed in Store entries
Values allowed in Store entries
Link to this section Types
An instruction to the Expander.Cache.Server to raise an error in the client.
Keys allowed in Store entries.
Values allowed in Store entries.