Browse Source

Added quick connectivity check.

Frederic G. MARAND 8 years ago
parent
commit
0b8d439e58
1 changed files with 21 additions and 0 deletions
  1. 21 0
      memcachetest.php

+ 21 - 0
memcachetest.php

@@ -0,0 +1,21 @@
+<?php
+
+$memcache = new Memcache;
+$memcache->connect('localhost', 11211) or die ("Could not connect");
+
+$version = $memcache->getVersion();
+echo "Server's version: ".$version."<br/>\n";
+
+$tmp_object = new stdClass;
+$tmp_object->str_attr = 'test';
+$tmp_object->int_attr = 123;
+
+$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
+echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";
+
+$get_result = $memcache->get('key');
+echo "Data from the cache:<br/>\n";
+
+var_dump($get_result);
+
+?>