Files
OMS/app/taskmgr/lib/interface/cache.php
2026-01-04 19:08:31 +08:00

67 lines
1.8 KiB
PHP

<?php
/**
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* 导出数据存储介质外部调用接口类
*
* @author kamisama.xia@gmail.com
* @version 0.1
*/
//加载配置信息
require_once(dirname(__FILE__) . '/../../config/config.php');
class taskmgr_interface_cache{
private static $__cacheObj;
public function __construct($task_id){
if(!isset(self::$__cacheObj)){
$cacheClass = sprintf('taskmgr_cache_%s', __CACHE_MODE);
self::$__cacheObj = new $cacheClass($task_id);
}
}
//存储数据
public function store($key, $value, $ttl=0){
return self::$__cacheObj->store($key, $value, $ttl);
}
//读取数据
public function fetch($key, &$result){
return self::$__cacheObj->fetch($key, $result);
}
//统计类数据自增
public function increment($key, $value){
return self::$__cacheObj->increment($key, $value);
}
//删除缓存数据
public function delete($key){
return self::$__cacheObj->delete($key);
}
//识别当前数据缓存模式,是否是本地存储模式
public function isLocalMode(){
if(defined('__CACHE_MODE') && strtolower(__CACHE_MODE) == 'filesystem'){
return true;
}else{
return false;
}
}
}