README.md

memcached

Memcached is High Performance, Distributed Memory Object Cache

Summary

  • Dockerfile - build container image with memcached.
  • openshift-template.yml - Template for OpenShift to memcached.

How to use the container over standard 11211 port

Command for running memcached docker container:

docker run -it -e CACHE_SIZE=128 \
    -p 11211:11211

If you would like to increase a CACHE_SIZE use environment variable -e CACHE_SIZE:

docker run -it -e CACHE_SIZE=128 \
    -p 11211:11211

How to run memcached as standalone container

Copy memcached-container.service to /usr/lib/systemd/user/ directory

sudo cp memcached-container.service /usr/lib/systemd/user/
systemctl --user daemon-reload

Command for running memcached as standalone container:

systemctl start --user memcached-container

How to stop memcached as standalone container

Command for stopping memcached as standalone container:

systemctl stop --user memcached-container

How to test the memcached

Commands for testing memcached docker container:

To store data in memcached server with telnet:

set KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES

To get data

get KEY

To overwrite existing key

replace KEY META_DATA EXPIRE_TIME LENGTH_IN_BYTES

To delete key

delete KEY

To get the server statistics

stats
stats items
stats slabs

To clear the metadata statistics

flush all

Memcached Server Telnet Example (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example)

set Test 0 100 10
JournalDev
STORED
get Test
VALUE Test 0 10
JournalDev
END
replace Test 0 100 4
Temp
STORED
get Test
VALUE Test 0 4
Temp
END
stats items
STAT items:1:number 1
STAT items:1:age 19
STAT items:1:evicted 0
STAT items:1:evicted_time 0
STAT items:1:outofmemory 0
STAT items:1:tailrepairs 0
END
flush_all
OK
get Test
END
version
VERSION 1.4.25
quit