Last active
May 9, 2024 12:44
-
-
Save alvaro-prieto/a087b96bbffa5e33f32eb222001db21b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Caché | |
La caché sirve para evitar consultas innecesarias a la BD, que seguramente no cambian frecuentemente. Se le asigna una key, y se comprueba si existe el objeto. Si no existe se calcula y se guarda, poniéndole una caducidad **en segundos** | |
```php | |
$keyCache='credencialesAlumno-'.$id; | |
$cacheCredenciales = $this->quid->db->getCache( $keyCache ); | |
if($cacheCredenciales){ | |
//operación costosa | |
}else{ | |
$this->quid->db->setCache($keyCache, "lo que quieras guardar aquí, puede ser un array", 10000); | |
} | |
``` | |
* **Si no funciona**, comprobar en el config.php | |
``` | |
if ($_GET["sincache"]) DEFINE("CACHE",false); else DEFINE("CACHE",true); //Caché general de memcached | |
//DEFINE("CACHE",false); | |
``` | |
* **Borrar la caché** en mi máquina local, abrimos la consola: | |
``` | |
exit | |
service memcached restart | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment