model.php 1.0 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * The model file of cache module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2024 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Gang Liu <liugang@chandao.com>
  8. * @package cache
  9. * @link https://www.zentao.net
  10. */
  11. class cacheModel extends model
  12. {
  13. /**
  14. * 清空缓存。
  15. * Clear the cache.
  16. *
  17. * @access public
  18. * @return void
  19. */
  20. public function clear($needStart = true)
  21. {
  22. /* 先关闭缓存防止清空缓存过程中有新的数据写入。Close the cache first to prevent new data from being written during the cache clearing process. */
  23. $needStop = $this->config->cache->enable;
  24. if($needStop) $this->loadModel('setting')->setItem('system.common.cache.enable', 0);
  25. $this->mao->clearCache();
  26. if($needStop && $needStart) $this->loadModel('setting')->setItem('system.common.cache.enable', 1);
  27. }
  28. }