Instance Access
For security reasons, Memcache instances in the cloud can only be accessed within the internal network. This document will provide a brief overview of how to access cloud Memcache instances using the Memcache protocol as an example.
Telnet access
telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
add id 1 0 4
1234
STORED
get id
VALUE id 1 4
1234
END
delete id
DELETED
Php access
<?php
$memcache = new Memcache;
$memcache->connect('10.4.7.17', 11211);
$key = "testkey";
$tvalue = "testvalue";
$memcache->set($key, $tvalue, false, 10);
$nvalue = $memcache->get($key);
print_r($nvalue . "\n");
?>
Python access example
#!/usr/bin/env python2
# coding=utf8
import sys, os
import time
import memcache
if __name__ == "__main__":
ip = '10.4.7.17'
port = 11211
addr = "%s:%d" % (ip , port)
mc = memcache.Client([addr], debug=0)
key = 'testkey'
tvalue = "testvalue"
mc.set(key, tvalue)
nvalue = mc.get(key)
print nvalue