b33d552
# memcached
b33d552
b33d552
Memcached is High Performance, Distributed Memory Object Cache
b33d552
5a4b8a6
## How to use the container
b33d552
5a4b8a6
Pull the image from Docker Hub:
b33d552
b33d552
```bash
5a4b8a6
$ sudo docker pull registry.fedoraproject.org/memcached:rawhide
b33d552
```
b33d552
5a4b8a6
Run the container
b33d552
b33d552
```bash
5a4b8a6
docker run -it -p 11211:11211 --name memcached modularitycontainers/memcached
b33d552
```
b33d552
5a4b8a6
If you would like to debug memcached, use container option =e MEMCACHED_DEBUG_MODE:
b33d552
```bash
5a4b8a6
docker run -it -p 11211:11211
5a4b8a6
[-e MEMCACHED_DEBUG_MODE]
5a4b8a6
--name memcached modularitycontainers/memcached
b33d552
```
b33d552
5a4b8a6
If you would like to change memcached options, like cache_size, connections or threads, use environment variable -e MEMCACHED_CACHE_SIZE, -e MEMCACHED_CONNECTIONS, -e MEMCACHED_THREADS respectively:
b33d552
```bash
5a4b8a6
docker run -it -p 11211:11211
5a4b8a6
[-e MEMCACHED_CACHE_SIZE=<size_in_MB>]
5a4b8a6
[-e MEMCACHED_CONNECTIONS=<max_simultaneous_connections>]
5a4b8a6
[-e MEMCACHED_THREADS=<max_concurrent_threads>]
5a4b8a6
--name memcached modularitycontainers/memcached
b33d552
```
b33d552
5a4b8a6
## A demo
5a4b8a6
5a4b8a6
Here is a simple demo how to run memcached
5a4b8a6
5a4b8a6
* Copy systemd service which will take care of memcached container: 
5a4b8a6
   ```bash
5a4b8a6
   $ sudo cp -av memcached-container.service /usr/lib/systemd/system/
5a4b8a6
   $ sudo systemctl daemon-reload
5a4b8a6
   ```
5a4b8a6
5a4b8a6
* We can start memcached now:
5a4b8a6
  ```bash
5a4b8a6
  $ sudo systemctl start memcached-container
5a4b8a6
  ```
5a4b8a6
5a4b8a6
* You should be able to test memcached by commands (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example):
5a4b8a6
  ```bash
5a4b8a6
  set Test 0 100 10
5a4b8a6
  JournalDev
5a4b8a6
  STORED
5a4b8a6
  get Test
5a4b8a6
  VALUE Test 0 10
5a4b8a6
  JournalDev
5a4b8a6
  END
5a4b8a6
  replace Test 0 100 4
5a4b8a6
  Temp
5a4b8a6
  STORED
5a4b8a6
  get Test
5a4b8a6
  VALUE Test 0 4
5a4b8a6
  Temp
5a4b8a6
  END
5a4b8a6
  stats items
5a4b8a6
  STAT items:1:number 1
5a4b8a6
  STAT items:1:age 19
5a4b8a6
  STAT items:1:evicted 0
5a4b8a6
  STAT items:1:evicted_time 0
5a4b8a6
  STAT items:1:outofmemory 0
5a4b8a6
  STAT items:1:tailrepairs 0
5a4b8a6
  END
5a4b8a6
  flush_all
5a4b8a6
  OK
5a4b8a6
  get Test
5a4b8a6
  END
5a4b8a6
  version
5a4b8a6
  VERSION 1.4.25
5a4b8a6
  quit
5a4b8a6
  ```
5a4b8a6
5a4b8a6
## Repository structure
b33d552
5a4b8a6
- Dockerfile - build container image with memcached.
5a4b8a6
- openshift-template.yml - Template for OpenShift to memcached.