PHP code example of genesis / method-persister

1. Go to this page and download the library: Download genesis/method-persister 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/ */

    

genesis / method-persister example snippets


namespace ABC\Example;

use Genesis\MethodPersister;

// Ideally done using a DI library.
$centralStoragePath = '/tmp/cache/';
$persistenceRepository = new MethodPersister\PersistenceRepository($centralStoragePath);
$persister = new MethodPersister\Persister($persistenceRepository);

$result = $myObject->myMethod($arg1, $arg2);

return $result;

$result = $persister->persist($myObject, 'myMethod')
	->withParameters($arg1, $arg2)
	->overAPeriodOf('+10 seconds')
	->execute();

// Use result as normal
return $result;

$result = $persister->persist($myObject, 'userSpecificData')
    ->withParameters($arg1, $arg2)
    ->overAPeriodOf('+10 seconds')
    ->in(PersisterInterface::STATE_DISTRIBUTE)
    ->execute();