Skip to content

Latest commit

 

History

History
153 lines (129 loc) · 3.6 KB

README.md

File metadata and controls

153 lines (129 loc) · 3.6 KB

anchor

High-Performance Erlang Memcached Client

Build Status Coverage Status

Requirements

  • Memcached
  • Erlang 16.0 +

Features

  • Backpressure via backlog (OOM protection)
  • Binary protocol
  • Fast pool implementation (random | round_robin)
  • Performance optimized
  • Request pipelining

API

Function Index

Environment variables

Name Type Default Description
backlog_size pos_integer() 1024 maximum number of concurrent requests per connection
ip list() "127.0.0.1" server ip
pool_size pos_integer() 16 number of connections
pool_strategy random | round_robin random connection selection strategy
port pos_integer() 9042 server port
reconnect boolean() true reconnect closed connections
reconnect_time_max boolean() true reconnect maximum time
reconnect_time_min boolean() true reconnect minimum time
socket_options [gen_tcp:connect_option()] [binary, {buffer, 65535}, {nodelay, true}, {packet, raw}, {send_timeout, 50}, {send_timeout_close, true}] options passed to the socket

Examples

1> anchor_app:start().
{ok, [shackle, anchor]}

2> anchor:get(<<"foo">>).
{error, key_not_found}

3> anchor:set(<<"foo">>, <<"bar">>, 3600).
ok

4> anchor:get(<<"foo">>).
{ok, <<"bar">>}

5> anchor:delete(<<"foo">>).
ok

6> {ok, Ref} = anchor:async_get(<<"foo">>).
{ok, {anchor_6, #Ref<0.0.1.1363>}}

7> anchor:receive_response(Ref, 1000).
{error, key_not_found}

Tests

make dialyzer
make elvis
make eunit
make xref

License

The MIT License (MIT)

Copyright (c) 2014-2017 Louis-Philippe Gauthier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.