file_path] = false; return false; } $bucket = $parsed['host']; $key = ltrim($parsed['path'], '/'); try { $result = check_file_on_S3bucket_cached($key, $bucket); $file_cache[$file_path] = $result; return $result ? true : false; } catch (Exception $e) { error_log("S3 file_exists failed for {$file_path}: " . $e->getMessage()); $file_cache[$file_path] = false; return false; } } $result = file_exists($file_path); $file_cache[$file_path] = $result; return $result; } /** * Get S3 cache statistics for monitoring */ function get_s3_cache_stats() { global $cache_DB; $stats = [ 'total_cached_files' => 0, 'cache_hit_rate' => 0, 'oldest_cache_entry' => null, 'newest_cache_entry' => null ]; try { if (isset($cache_DB) && is_object($cache_DB)) { $results = $cache_DB->get_results("SELECT COUNT(*) as total, MIN(cache_timestamp) as oldest, MAX(cache_timestamp) as newest FROM bidx_querycache WHERE cache_key LIKE 's3_%'"); if (!empty($results)) { $stats['total_cached_files'] = $results[0]->total; $stats['oldest_cache_entry'] = $results[0]->oldest ? date('Y-m-d H:i:s', $results[0]->oldest) : null; $stats['newest_cache_entry'] = $results[0]->newest ? date('Y-m-d H:i:s', $results[0]->newest) : null; } } } catch (Exception $e) { error_log("Failed to get S3 cache stats: " . $e->getMessage()); } return $stats; } /** * Clear expired S3 cache entries */ function cleanup_s3_cache($max_age_hours = 24) { global $cache_DB; try { if (isset($cache_DB) && is_object($cache_DB)) { $cutoff_time = time() - ($max_age_hours * 3600); $result = $cache_DB->query("DELETE FROM bidx_querycache WHERE cache_key LIKE 's3_%' AND cache_timestamp < {$cutoff_time}"); if ($result !== false) { error_log("Cleaned up S3 cache entries older than {$max_age_hours} hours"); return true; } } } catch (Exception $e) { error_log("Failed to cleanup S3 cache: " . $e->getMessage()); } return false; } /** * Invalidate specific S3 cache entry */ function invalidate_s3_cache($filename, $s3Bucket = null, $s3_server = 'default') { global $cache_DB; if (!$s3Bucket) { global $_S3_TAB_SETTINGS; $s3Bucket = $_S3_TAB_SETTINGS[$s3_server]['bucket'] ?? _S3_BUCKET_NAME; } $cache_key = "s3_exists_{$s3Bucket}_{$filename}"; try { if (isset($cache_DB) && is_object($cache_DB)) { $cache_DB->query("DELETE FROM bidx_querycache WHERE cache_key = '{$cache_key}'"); } static $memory_cache = []; unset($memory_cache[$cache_key]); return true; } catch (Exception $e) { error_log("Failed to invalidate S3 cache for {$filename}: " . $e->getMessage()); return false; } } ?>
PRICED AT ONLY: $200,000
Address: 911 Candlebrook Lane, Brooksville, FL 34601