53 global $UserCacheStat;
56 if (rand(1, 500) == 1) {
64 if ($UserCacheStat == 0) {
65 $sql =
"SELECT cache_on FROM report_cache_user WHERE user_fk='$_SESSION[UserId]';";
66 $result = pg_query($PG_CONN, $sql);
68 $row = pg_fetch_assoc($result);
69 pg_free_result($result);
70 if (! empty($row[
'cache_on']) && ($result[
'cache_on'] ==
'N')) {
76 $EscKey = pg_escape_string($CacheKey);
79 $sql =
"UPDATE report_cache SET report_cache_tla = now() WHERE report_cache_key='$EscKey';";
80 $result = pg_query($PG_CONN, $sql);
82 pg_free_result($result);
85 $sql =
"SELECT report_cache_value FROM report_cache WHERE report_cache_key='$EscKey';";
86 $result = pg_query($PG_CONN, $sql);
88 $row = pg_fetch_assoc($result);
89 $cashedvalue = $row[
'report_cache_value'];
90 pg_free_result($result);
105 global $UserCacheStat;
112 if ($UserCacheStat == 2) {
116 $EscKey = pg_escape_string($CacheKey);
117 $EscValue = pg_escape_string($CacheValue);
122 $ParsedURI = array();
123 parse_str($EscKey, $ParsedURI);
125 if (array_key_exists(
"upload", $ParsedURI)) {
126 $Upload = $ParsedURI[
'upload'];
128 if (array_key_exists(
"item", $ParsedURI)) {
129 $sql =
"SELECT upload_fk FROM uploadtree WHERE uploadtree_pk='$ParsedURI[item]';";
130 $result = pg_query($PG_CONN, $sql);
133 $row = pg_fetch_assoc($result);
134 $Upload = $row[
'upload_fk'];
135 pg_free_result($result);
137 if (empty($Upload)) {
141 $sql =
"INSERT INTO report_cache (report_cache_key, report_cache_value, report_cache_uploadfk) 142 VALUES ('$EscKey', '$EscValue', $Upload);";
143 $result = pg_query($PG_CONN, $sql);
145 pg_free_result($result);
146 $PGError = pg_last_error($PG_CONN);
148 if (strpos($PGError,
"uplicate") > 0) {
149 $sql =
"UPDATE report_cache SET report_cache_value = '$EscValue', " .
150 "report_cache_tla=now() WHERE report_cache_key = '$EscKey';";
151 $result = pg_query($PG_CONN, $sql);
153 pg_free_result($result);
163 $sql =
"DELETE FROM report_cache;";
164 $result = pg_query($PG_CONN, $sql);
166 pg_free_result($result);
178 $sql =
"DELETE FROM report_cache WHERE report_cache_tla < $PurgeDate;";
179 $result = pg_query($PG_CONN, $sql);
181 pg_free_result($result);
193 $sql =
"DELETE FROM report_cache WHERE report_cache_uploadfk = $UploadPK;";
194 $result = pg_query($PG_CONN, $sql);
196 pg_free_result($result);
210 $ParsedURI = array();
211 $EscKey = pg_escape_string($CacheKey);
212 parse_str($EscKey, $ParsedURI);
214 $sql =
"DELETE FROM report_cache WHERE report_cache_key = '$EscKey';";
215 $result = pg_query($PG_CONN, $sql);
217 $Err = pg_last_error($PG_CONN);
218 pg_free_result($result);
ReportCachePut($CacheKey, $CacheValue)
This function is used to write a record to the report cache. If the record already exists...
ReportCachePurgeByUpload($UploadPK)
Purge from the report cache records for upload $UploadPK.
ReportCachePurgeByKey($CacheKey)
Purge from the report cache the record with $CacheKey.
ReportCachePurgeByDate($PurgeDate)
Purge from the report cache records that have been accessed previous to $PurgeDate.
ReportCachePurgeAll()
Purge all records from the report cache.
ReportCacheGet($CacheKey)
This function is used by Output() to see if the requested report is in the report cache...
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.