// Start APCu cache apcu_store('my_key', 'my_value'); // Fetch data from cache $data = apcu_fetch('my_key'); // Output cached data echo $data;
// Create Memcached instance and add server $memcached = new Memcached(); $memcached->addServer('localhost', 11211); // Set data in cache $memcached->set('my_key', 'my_value', 600); // Fetch data from cache $data = $memcached->get('my_key'); // Output cached data echo $data;Both examples above show how to fetch data from a cache using different package libraries. The first example uses the APCu package library, while the second example uses the Memcached package library.