// create a new Memcached object $memcache = new Memcached(); // add server to the Memcached object $memcache->addServer('localhost', 11211); // store a value in the cache $memcache->set('key1', 'value1', 3600); // retrieve a value from the cache $value = $memcache->get('key1');
// store a value in APCu cache apcu_store('key1', 'value1', 3600); // retrieve a value from APCu cache $value = apcu_fetch('key1');In this code, we store a value with the key 'key1' and a timeout of 3600 seconds (1 hour) in the APCu cache. We then retrieve the value associated with 'key1' from the cache using the `apcu_fetch()` function.