0

I am searching for a tutorials about Memcache from php.net. Here is the list of what I am searching and reasons of it.

Memcache tutorials that works for PHP 7, reason is, on the cPanel, the version of is PHP 7. Memcache that works for both PHP 7 and windows 7 os, reason is I need to test it to my localhost, before applying it to production.

News:

As of now, I searched for virtualbox or alike where I can use it to install Linux, so that, maybe, I can run the Memcache with PHP 7. This is for the last resort though. If you guys have links for tutorials, or advices and suggestions on how I can solve my questions, please inform me. Thank you.

Additional

I tried to run this code in production:

<?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);

?>

It returns 1, so I guess it's working right?

Da Heel
  • 141
  • 1
  • 5
  • Just to clarify - you probably want to be using the [memcached](http://stackoverflow.com/questions/1442411/when-should-i-use-memcache-instead-of-memcached) extension, not memcache. Pretty sure memcache won't compile for PHP 7, and maybe not even PHP 5.6 – drew010 Oct 03 '16 at 23:32
  • Uhm, I am not pretty sure, but the code above that I saw in memcache extension, is the one that I run on the production site, what do you think? – Da Heel Oct 04 '16 at 03:42
  • The php extensions "memcache" and "memcached" both talk to memcache servers, but the "memcached" extension is newer, more supported, and has more features (like persistent connections). – drew010 Oct 04 '16 at 16:09
  • do you have tutorial links, I want to try it to my laptop before I implement it to the production – Da Heel Oct 05 '16 at 00:19
  • It's fairly straightforward to use, there are a few decent examples at https://github.com/php-memcached-dev/php-memcached/tree/master/server-example – drew010 Oct 05 '16 at 16:08

0 Answers0