Expander v0.0.1 Expander View Source

A library to expand/unshorten urls with unified cache store.

![Version][hex-version-badge]][hex] [![Downloads][hex-downloads-badge]][hex] [![License][hex-license-badge]][hex] [![Dependencies][deps-badge]][deps] [![Documentation][docs-badge]

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 IntegrationTest Coverage
MasterBuild StatusCoverage Status
DevelopmentBuild StatusCoverage Status

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

  1. Add expander to your list of dependencies in mix.exs:

    def deps do
      [{:expander, "~> 0.0.1"}]
    end
  2. (Optional - only for Elixir < 1.4) Ensure expander is started before your application:

    def application do
      [applications: [:expander]]
    end
  3. (Optional) If you are using Expander.Cache.Adapter.Redix or Expander.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

Link to this type exception() View Source
exception() :: {:raise, Module.t, raise_opts :: Keyword.t}

An instruction to the Expander.Cache.Server to raise an error in the client.

Keys allowed in Store entries.

Link to this type value() View Source
value() :: term

Values allowed in Store entries.