PHP code example of neoacevedo / yii2-fastly-cache
1. Go to this page and download the library: Download neoacevedo/yii2-fastly-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/ */
// Guardar datos en caché
Yii::$app->cache->set('mi_clave', 'mi_valor', 3600);
// Obtener datos de caché
$valor = Yii::$app->cache->get('mi_clave');
// Verificar si existe una clave
if (Yii::$app->cache->exists('mi_clave')) {
// La clave existe
}
// Eliminar una clave
Yii::$app->cache->delete('mi_clave');
use yii\caching\FileDependency;
$dependency = new FileDependency(['fileName' => 'path/to/file.txt']);
Yii::$app->cache->set('mi_clave', 'mi_valor', 3600, $dependency);
use yii\caching\TagDependency;
// Guardar con tags
Yii::$app->cache->set('usuario_1', $userData, 3600, new TagDependency(['tags' => 'usuarios']));
// Invalidar por tag
TagDependency::invalidate(Yii::$app->cache, 'usuarios');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.