Home

Awesome

<a href="http://tarantool.org"> <img src="https://avatars2.githubusercontent.com/u/2344919?v=2&s=250" align="right"> </a>

Static analysis Testing

memcached

Memcached protocol 'wrapper' for Tarantool.

Getting started

Prerequisites

Installation

Clone this repository and then build it using CMake:

git clone https://github.com/tarantool/memcached.git
cd memcached
git submodule update --init --recursive
cmake . -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DCMAKE_INSTALL_PREFIX=/usr
make
make install

Or use LuaRocks (in this case you'll need libsmall, libsmall-dev, tarantool-dev packages available from our binary repository at http://tarantool.org/dist/master, and system package libsasl2-dev):

luarocks install https://raw.githubusercontent.com/tarantool/memcached/master/rockspecs/memcached-scm-1.rockspec --local

Usage

box.cfg{}
local memcached = require('memcached')
local instance = memcached.create('my_instance', '0.0.0.0:11211')

Now you're set up and ready to go!

How to connect

Install Tarantool package from repository (described here).

Paste the previous example to /etc/tarantool/instances.enabled/memcached.lua and start it with tarantoolctl start memcached.

Then try the following example:

$ printf "set key 0 60 5\r\nvalue\r\n" | nc localhost 11211
STORED
$ printf "get key\r\n" | nc localhost 11211
VALUE key 0 5
value
END
$ printf "set key2 0 60 6\r\nvalue2\r\n" | nc localhost 11211
STORED
$ printf "get key key2\r\n" | nc localhost 11211
VALUE key 0 5
value
VALUE key2 0 6
value2
END

API

Configuration

SASL support

Usual rules for memcached are applicable for this plugin:

  1. Create user (NOTE: it'll use custom folder):

    echo testpass | saslpasswd2 -p -c testuser -f /tmp/test-tarantool-memcached.sasldb
    
  2. Place configuration file /etc/sasl2/tarantool-memcached.conf. For example:

    mech_list: plain cram-md5
    log_level: 7
    sasldb_path: /tmp/test-tarantool-memcached.sasldb
    

    NOTE: This will disable 'ANONYMOUS' (and other, that aren't listed) authentication plugins.

    NOTE: This will set logging level to the highest possible

    NOTE: This will set custom path for database path

  3. Run Tarantool with memcached plugin with SASL enabled

    local memcached = require('memcached')
    local instance = memcached.create('my_instance', '0.0.0.0:11211', {
      sasl = true
    })
    
  4. Use your favorite binary(!!) memcached client, that supports(!!) SASL:

    Example using Python's 'python-binary-memcached' library

    import bmemcached
    client = bmemcached.Client(('127.0.0.1:11211', ), 'testuser', 'testpasswd')
    client.set('key', 'value')
    print(client.get('key'))
    

For custom configuration file path, please, use SASL_CONF_PATH environment variable.

What's supported, what's not and other features

Everything is supported, unless the opposite is stated explicitly

Caution

This rock is in early beta.

Hacking

We're collecting information for the module developers in the HACKING.md file.