How to setup Memcached for local development

Kobe
1 min readAug 7, 2021

--

This article guides you on how to set up a Memcached local — support for our development.

MAC Env: Install with Homebrew

Install memcached with Homebrew

brew install memcached

Try to stop and start memcached from cmd

brew services start memcached
brew services restart memcached
brew services stop memcached

Output

(base) haithai@FVFY201CHV2H ~ % brew services stop memcached
Stopping `memcached`... (might take a while)
==> Successfully stopped `memcached` (label: homebrew.mxcl.memcached)
(base) haithai@FVFY201CHV2H ~ % brew services start memcached
==> Successfully started `memcached` (label: homebrew.mxcl.memcached)
(base) haithai@FVFY201CHV2H ~ %

Verify memcached — make sure it is working correctly

Using the Memcached Telnet Interface You can connect to the Memcached server with Telnet.

telnet localhost 11211

Set/Get a Cache Item (The basic syntax of the command is set as follows)

# cmd for set a key with options
set key flags exptime bytes [noreply]
value
# cmd for get a key ( return a value )
get key

Example

(base) haithai@FVFY201CHV2H ~ % telnet localhost 11211               
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set mykey 0 900 5
hello
STORED
get mykey
VALUE mykey 0 5
hello
END

--

--

Kobe
Kobe

Written by Kobe

I’m working at KMS-Technology company. I love code (▀̿Ĺ̯▀̿ ̿) — Full Stack Software Engineer

No responses yet