PHP code example of onoi / blob-store

1. Go to this page and download the library: Download onoi/blob-store 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/ */

    

onoi / blob-store example snippets


class Foo {

	private $blobStore;

	public function __construct( BlobStore $blobStore ) {
		$this->blobStore = $blobStore;
	}

	public function doSomethingFor( $id ) {
		$container = $this->blobStore->read( md5( $id ) );

		$container->set( 'one', array( new \stdClass, 'Text' ) );

		$container->append(
			'one',
			new \stdClass
		);

		$container->delete( 'two' );

		$this->blobStore->save( $container );
	}
}

$cacheFactory = new CacheFactory();

$compositeCache = $cacheFactory->newCompositeCache( array(
	$cacheFactory->newFixedInMemoryLruCache(),
	$cacheFactory->newDoctrineCache( new \Doctrine\Common\Cache\RedisCache( ... ) )
) );

or

$compositeCache = $cacheFactory->newCompositeCache( array(
	$cacheFactory->newFixedInMemoryLruCache(),
	$cacheFactory->newMediaWikiCache( \ObjectCache::getInstance( 'redis' ) )
) );

$blobStore = new BlobStore( 'foo', $compositeCache );

$instance = new Foo( $blobStore );
$instance->doSomethingFor( 'bar' );