1. Go to this page and download the library: Download bigdevwhale/cachetastic 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/ */
bigdevwhale / cachetastic example snippets
// Import the CacheService class
use Cachetastic\Cachetastic;
// Create an instance of CacheService
$cacheService = new Cachetastic(
new YourApiService(), // The service or object to call the method on.
'fetchData', // The name of the method to call on the service.
[1, 2] // An array of parameters to pass to the method.
);
// Customize the cache duration (optional)
$cacheService->setCacheDuration(60);
// Cache the result of your API call
$result = $cacheService->retrieveOrCache();
// Force a clear of the cached data if needed
$cacheService->forceClear();
// You can also use the optional $regenerate parameter to control if data should be regenerated
$result = $cacheService->forceRefresh(false)
use Cachetastic\Cachetastic;
use YourApiService;
// Create an instance of Cachetastic to cache the result of a regular method
$cacheService = new Cachetastic(
new YourApiService(), // The service or object to call the method on.
'fetchData', // The name of the method to call on the service.
[1, 2] // An array of parameters to pass to the method.
);
// Customize the cache duration (optional)
$cacheService->setCacheDuration(60);
// Cache the result of your API call, whether it's a regular method
$result = $cacheService->retrieveOrCache();
// Create an instance of Cachetastic to cache the result of a static method
$cacheServiceStatic = new Cachetastic(
YourApiService::class, // The class with the static method.
'fetchDataStatic', // The name of the static method to call.
[1, 2] // An array of parameters to pass to the static method.
);
// Cache the result of your API call, whether it's a static method
$resultStatic = $cacheServiceStatic->retrieveOrCache();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.