2025-11-03 21:50:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
2025-11-30 22:26:37 +01:00
|
|
|
function getCachedMarkdown(string $filePath, string $langPrefix = ''): ?string {
|
2025-11-03 21:50:43 +01:00
|
|
|
$cacheDir = '/tmp/folderweb_cache';
|
|
|
|
|
$mtime = filemtime($filePath);
|
2025-11-30 22:26:37 +01:00
|
|
|
$cacheKey = md5($filePath . $mtime . $langPrefix);
|
2025-11-03 21:50:43 +01:00
|
|
|
$cachePath = "$cacheDir/$cacheKey";
|
|
|
|
|
|
|
|
|
|
if (file_exists($cachePath)) {
|
|
|
|
|
return file_get_contents($cachePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-30 22:26:37 +01:00
|
|
|
function setCachedMarkdown(string $filePath, string $html, string $langPrefix = ''): void {
|
2025-11-03 21:50:43 +01:00
|
|
|
$cacheDir = '/tmp/folderweb_cache';
|
|
|
|
|
if (!is_dir($cacheDir)) {
|
|
|
|
|
mkdir($cacheDir, 0755, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mtime = filemtime($filePath);
|
2025-11-30 22:26:37 +01:00
|
|
|
$cacheKey = md5($filePath . $mtime . $langPrefix);
|
2025-11-03 21:50:43 +01:00
|
|
|
$cachePath = "$cacheDir/$cacheKey";
|
|
|
|
|
|
|
|
|
|
file_put_contents($cachePath, $html);
|
|
|
|
|
}
|