42 global $UserCacheStat;
45 if (random_int(1, 500) == 1) {
53 if ($UserCacheStat == 0) {
54 $sql =
"SELECT cache_on FROM report_cache_user WHERE user_fk='$_SESSION[UserId]';";
57 $row = pg_fetch_assoc($result);
58 pg_free_result($result);
59 if (! empty($row[
'cache_on']) && ($result[
'cache_on'] ==
'N')) {
65 $EscKey = pg_escape_string($CacheKey);
68 $sql =
"UPDATE report_cache SET report_cache_tla = now() WHERE report_cache_key='$EscKey';";
71 pg_free_result($result);
74 $sql =
"SELECT report_cache_value FROM report_cache WHERE report_cache_key='$EscKey';";
77 $row = pg_fetch_assoc($result);
81 $cashedvalue = $row[
'report_cache_value'];
82 pg_free_result($result);
97 global $UserCacheStat;
104 if ($UserCacheStat == 2) {
108 $EscKey = pg_escape_string($CacheKey);
109 $EscValue = pg_escape_string($CacheValue);
114 $ParsedURI = array();
115 parse_str($EscKey, $ParsedURI);
117 if (array_key_exists(
"upload", $ParsedURI)) {
118 $Upload = $ParsedURI[
'upload'];
120 if (array_key_exists(
"item", $ParsedURI)) {
121 $sql =
"SELECT upload_fk FROM uploadtree WHERE uploadtree_pk='$ParsedURI[item]';";
125 $row = pg_fetch_assoc($result);
126 $Upload = $row[
'upload_fk'];
127 pg_free_result($result);
129 if (empty($Upload)) {
133 $sql =
"INSERT INTO report_cache (report_cache_key, report_cache_value, report_cache_uploadfk)
134 VALUES ('$EscKey', '$EscValue', $Upload);";
137 pg_free_result($result);
140 if (strpos($PGError,
"uplicate") > 0) {
141 $sql =
"UPDATE report_cache SET report_cache_value = '$EscValue', " .
142 "report_cache_tla=now() WHERE report_cache_key = '$EscKey';";
145 pg_free_result($result);
155 $sql =
"DELETE FROM report_cache;";
158 pg_free_result($result);
170 $sql =
"DELETE FROM report_cache WHERE report_cache_tla < $PurgeDate;";
173 pg_free_result($result);
185 $sql =
"DELETE FROM report_cache WHERE report_cache_uploadfk = $UploadPK;";
188 pg_free_result($result);
202 $ParsedURI = array();
203 $EscKey = pg_escape_string($CacheKey);
204 parse_str($EscKey, $ParsedURI);
206 $sql =
"DELETE FROM report_cache WHERE report_cache_key = '$EscKey';";
210 pg_free_result($result);
ReportCacheGet($CacheKey)
This function is used by Output() to see if the requested report is in the report cache.
ReportCachePurgeByDate($PurgeDate)
Purge from the report cache records that have been accessed previous to $PurgeDate.
ReportCachePut($CacheKey, $CacheValue)
This function is used to write a record to the report cache. If the record already exists,...
ReportCachePurgeByKey($CacheKey)
Purge from the report cache the record with $CacheKey.
ReportCachePurgeAll()
Purge all records from the report cache.
ReportCachePurgeByUpload($UploadPK)
Purge from the report cache records for upload $UploadPK.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN