PHP code example of thecodingmachine / stash-universal-module
1. Go to this page and download the library: Download thecodingmachine/stash-universal-module library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thecodingmachine / stash-universal-module example snippets
use Psr\Cache\CacheItemPoolInterface
$cachePool = $container->get(CacheItemPoolInterface::class);
echo $cachePool->getItem('my_cached_value')->get();
use Psr\Cache\CacheItemPoolInterface
// Let's assume we are using Simplex as our container
$container = new Simplex\Container();
// Registers a default service provider
$container->register(new StashServiceProvider());
// Registers another service provider for a shared memcache pool
$container->register(new StashServiceProvider('shared'));
// Lets configure the second service provider.
$container['stash.shared.memcache.options'] = [
'servers' => ['127.0.0.1', '11211']
];
// Let's override the composite options to put an ephemeral driver and the memcache driver next.
$container['stash.composite.options'] = function(ContainerInterface $container) {
return [
$container->get(Ephemeral::class),
$container->get(Memcache::class)
];
}
$defaultCachePool = $container->get(CacheItemPoolInterface::class);
//... do stuff with the default pool
// The shared memcache pool can be accessed by suffixing the instance with ".shared".
$sharedCachePool = $container->get(CacheItemPoolInterface::class.'.shared');
//... do stuff