m_config.auto_cache.php 671 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class m_config_auto_cache extends auto_cache{
  3. private $key = "m_config:list";
  4. public function load($param,$is_real=true)
  5. {
  6. $m_config = $GLOBALS['cache']->get($this->key);
  7. if($m_config === false)
  8. {
  9. $m_config = array();
  10. $sql = "select code,val from ".DB_PREFIX."m_config";
  11. $list = $GLOBALS['db']->getAll($sql);
  12. foreach($list as $item){
  13. $m_config[$item['code']] = $item['val'];
  14. }
  15. //print_r($list);
  16. $GLOBALS['cache']->set($this->key,$m_config,20,true);
  17. }
  18. return $m_config;
  19. }
  20. public function rm($param)
  21. {
  22. $GLOBALS['cache']->rm($this->key);
  23. }
  24. public function clear_all()
  25. {
  26. $GLOBALS['cache']->rm($this->key);
  27. }
  28. }
  29. ?>