1. Go to this page and download the library: Download daraniya/cache-graph 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/ */
daraniya / cache-graph example snippets
return [
// Enable/disable graph tracking while keeping cache operations working
'enabled' => env('CACHE_GRAPH_ENABLED', true),
// Auto-load package migrations only when explicitly enabled
'auto_load_migrations' => env('CACHE_GRAPH_AUTO_LOAD_MIGRATIONS', false),
// Storage driver: "json", "redis", "database"
'driver' => env('CACHE_GRAPH_DRIVER', 'json'),
// Path for the JSON/NDJSON storage
'path' => storage_path('app/cache-graph'),
// Redis connection to use for the redis driver
'redis_connection' => env('CACHE_GRAPH_REDIS_CONNECTION', 'default'),
// Database connection to use for the database driver
'database_connection' => env('CACHE_GRAPH_DATABASE_CONNECTION'),
// Default Cache TTL
'ttl' => env('CACHE_GRAPH_TTL', 3600),
// Enable/disable storage overhead monitoring
'store_stats' => env('CACHE_GRAPH_STORE_STATS', true),
];
use Daraniya\CacheGraph\Facades\CacheGraph;
$userProfile = CacheGraph::remember('user_profile_1', 3600, function () {
return User::find(1)->toProfileArray();
}, ['users_table', 'user:1']);
// Retrieve a value and automatically increment hit/miss counters
$profile = CacheGraph::get('user_profile_1');
// Cache a value and link it to dependencies
CacheGraph::put('user_profile_1', $profileData, 3600, ['users_table', 'user:1']);