PHP code example of nodes / cache

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

    

nodes / cache example snippets


Nodes\Cache\ServiceProvider::class

'NodesCache' => Nodes\Cache\Support\Facades\Cache::class

function cache_remember($cacheGroupKey, array $params = [], $data, $tags = null, \Closure $closure = null)

function cache_put($cacheGroupKey, array $params = [], $data, $tags = null)

function cache_get($cacheGroupKey, array $params = [], $tags = null)

function cache_forget($cacheGroupKey, array $params = [], $tags = null)

function cache_flush($tags)

function cache_wipe()

\NodesCache::remember($cacheGroupKey, array $params = [], $data, $tags = null, \Closure $closure = null)

\NodesCache::put($cacheGroupKey, array $params = [], $data, $tags = null)

\NodesCache::get($cacheGroupKey, array $params = [], $tags = null)

\NodesCache::forget($cacheGroupKey, array $params = [], $tags = null)

\NodesCache::flush($tags)

\NodesCache::wipe()
bash
php artisan vendor:publish --provider="Nodes\Cache\ServiceProvider"
bash
php artisan vendor:publish --provider="Nodes\Cache\ServiceProvider" --force

return cache_remember('geographic.continent.bySlug', ['slug' => $slug], $tags, function () use ($slug) {

	// Look up in db
	$continent = $this->where('slug', $slug)->first();

	if (!$continent) {
		throw new EntityNotFoundException(sprintf('Could not find continent with slug [%s]', $slug));
	}

	return $continent;
});

// Look up in db
$continent = $this->where('slug', $slug)->first();
if (!$continent) {
	throw new EntityNotFoundException(sprintf('Could not find continent with slug [%s]', $slug));
}

// Put in cache
$success = cache_put('geographic.continent.bySlug', ['slug' => $slug], $continent)