3
class CACHEReader extends READER {
6
function __construct(&$props, CACHEDB &$cache = NULL) {
7
parent::__construct($props);
8
if ($cache) $this->cache = &$cache;
10
if ($props instanceof SOURCERequest)
11
$this->cache = new CACHEDB($props);
17
function GetGroupInfo(LOGGROUP &$grp = NULL, $flags = 0) {
20
$res = $this->cache->ListCachedGroups();
21
foreach ($res as $gid) {
22
if (($grp)&&(strcmp($grp->gid, $gid))) continue;
24
$groups[$gid] = array(
29
if ($flags&READER::NEED_INFO) {
30
$postfix = $this->cache->GetCachePostfix($gid);
33
if ($flags&READER::NEED_COUNT) $flags |= CACHEDB::NEED_COUNT;
34
$info = $this->cache->GetCacheInfo($postfix, $flags);
37
throw new ADEIException(translate("The CACHE for group (%s) is empty", $grp->gid));
39
foreach ($info as $key => &$value) {
40
$groups[$gid][$key] = $value;
43
if ($flags&READER::NEED_ITEMINFO) {
44
$groups[$gid]['items'] = $this->cache->GetCacheItemList($postfix);
49
return $grp?$groups[$grp->gid]:$groups;
52
function GetItemList(LOGGROUP &$grp = NULL, MASK &$mask = NULL, $flags = 0) {
53
$grp = $this->CheckGroup($grp);
55
$postfix = $this->cache->GetCachePostfix($grp->gid);
56
if (!$mask) $mask = $this->CreateMask($grp);
58
return $this->cache->GetCacheItemList($postfix, $mask, 0);
61
function GetData(LOGGROUP &$grp = NULL, $from = 0, $to = 0) {
62
$grp = $this->CheckGroup($grp);
64
$postfix = $this->cache->GetCachePostfix($grp->gid);
66
$ivl = $this->CreateInterval($grp);
67
$ivl->Limit($from, $to);
71
return $this->cache->GetCachePoints($postfix, $mask, $ivl, CACHEDB::TYPE_ALL);
74
function HaveData(LOGGROUP &$grp = NULL, $from = 0, $to = 0) {
75
$grp = $this->CheckGroup($grp);
77
$postfix = $this->cache->GetCachePostfix($grp->gid);
79
$ivl = $this->CreateInterval($grp);
80
$ivl->Limit($from, $to);
84
$points = $this->cache->GetCachePoints($postfix, $mask, $ivl, CACHEDB::TYPE_ALL, 1);
87
return $points->valid();
b'\\ No newline at end of file'