1. Go to this page and download the library: Download cleup/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/ */
cleup / cache example snippets
use Cleup\Cache\CacheManager;
// Configure cache drivers
CacheManager::configure([
'default' => 'local', // or 'type:namespace'
'local' => [
'storage_path' => '/path/to/cache',
'default_ttl' => 3600
],
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'prefix' => 'app:'
]
'local:myapp' => [
// ...
],
'redis:new_server': [
// ...
],
'memcached:sessions' => [
// ...
]
]);
// Use the default driver
CacheManager::set('key', 'value', 3600);
$value = CacheManager::get('key');
// Use a driver with a specific type and namespace.
CacheManager::driver('redis:new_server')->set('key', 'value');
CacheManager::driver('memcached:sessions')->get('key');
use Cleup\Cache\Drivers\LocalDriver;
use Cleup\Cache\Cache;
// Local file driver
$localDriver = new LocalDriver([
'storage_path' => '/tmp/cache',
'default_ttl' => 3600
]);
// Or
$localDriver = (new LocalDriver())
->storagePath('/tmp/cache')
->defaultTtl(3600);
$cache = new Cache($localDriver);
$user = ['id' => 1, 'name' => 'Eduard'];
$cache->set('user', $user, 1800);
$cahe->get('user');
// Use default driver
CacheManager::set('key', 'value');
$value = CacheManager::get('key');
// Get value by key
$user = cache('user');
// Equivalent to:
$user = CacheManager::get('user');
// Set value with key
cache('user', $userData, 3600);
// Equivalent to:
CacheManager::set('user', $userData, 3600);
# Set Value with TTL
// Set value with specific TTL (using method chaining)
cache()->set('user:123', $userData, 3600);
// Or using the manager directly
cache('user:123', $userData, 3600); // Note: This syntax
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.