控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Cache.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 缓存类
  13. // +----------------------------------------------------------------------
  14. namespace app\common\library;
  15. use app\common\model\Cache as CacheModel;
  16. use think\Exception;
  17. class Cache
  18. {
  19. /**
  20. * 安装插件注册缓存
  21. * @param array $cache 缓存配置
  22. * @param array $config 模块配置
  23. * @return boolean
  24. */
  25. public static function installAddonCache(array $cache, array $config)
  26. {
  27. if (empty($cache) || empty($config)) {
  28. throw new Exception('参数不完整!');
  29. }
  30. $module = $config['name'];
  31. foreach ($cache as $key => $rs) {
  32. $add = array(
  33. 'key' => $key,
  34. 'name' => $rs['name'],
  35. 'module' => isset($rs['module']) ? $rs['module'] : $module,
  36. 'model' => $rs['model'],
  37. 'action' => $rs['action'],
  38. //'param' => isset($rs['param']) ? $rs['param'] : '',
  39. 'system' => 0,
  40. );
  41. CacheModel::create($add);
  42. }
  43. return true;
  44. }
  45. /**
  46. * 删除指定插件下的全部缓存队列
  47. * @param type $addon 插件名称
  48. * @return boolean
  49. */
  50. public static function deleteCacheAddon($addon)
  51. {
  52. CacheModel::destroy(['module' => $addon, 'system' => 0]);
  53. return true;
  54. }
  55. }