Saltar al contenido

cómo funciona el caché en el ejemplo de código codeigniter

Intenta interpretar el código bien antes de adaptarlo a tu trabajo si tdeseas aportar algo puedes compartirlo con nosotros.

Ejemplo 1: datos de caché en codeigniter

if(!function_exists('getCacheSettings'))functiongetCacheSettings($key)if($cacheSettingValue=checkCachedValue($key))return$cacheSettingValue;$ci=&get_instance();$result=$ci->db->get_where('settings',array('key'=>$key));if($result->num_rows()>0)$fetchData=$result->row();cacheFetchedData($key,base64_decode($fetchData->value));returnbase64_decode($fetchData->value);returnnull;if(!function_exists('checkCachedValue'))functioncheckCachedValue($key)$ci=&get_instance();$ci->load->driver('cache',array('adapter'=>'file'));$cacheKeyData=$ci->cache->get("icd10_".$key);return!empty($cacheKeyData)?$cacheKeyData:false;if(!function_exists('cacheFetchedData'))functioncacheFetchedData($key,$fetchedData)$ci=&get_instance();$ci->load->driver('cache',array('adapter'=>'file'));// Save into the cache for 12 Hours$ci->cache->save('icd10_'.$key,$fetchedData,60*60*12);return$fetchedData;getCacheSettings('KEY_NAME');$this->cache->delete('cache_item_id');

This method will ‘clean’ the entire cache.If the deletion of the cache files
fails, the method will returnFALSE.$this->cache->clean();refrence:https://www.codeigniter.com/userguide3/libraries/caching.html#example-usage

Ejemplo 2: caché de la página web de codeigniter basada en el usuario

class MY_Output extendsCI_Output

Tienes la opción de añadir valor a nuestro contenido contribuyendo tu veteranía en los informes.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *