Memcache test connection script

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
error_reporting(E_ALL);
$memcache = new Memcache;
// Connect to memcached server
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");

// Add it to memcached server
// The parameters are: KEY, VALUE, USE COMPRESSION, EXPIRY IN SECONDS
$memcache->set('MyKey1', 'The value of My Key1 is me', false, 100);
 
echo $memcache->get('MyKey1');
// It will show you: The value of My Key1 is me
?>
This entry was posted in php, Web Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


× two = 6