İlk temizlik tamamlandı bir önceki projeden

This commit is contained in:
Ümit Tunç
2026-04-28 21:14:25 +03:00
commit f80443aec0
10000 changed files with 959965 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
<?php
function convertMapCache() {
// Converter-map verilerini al
$converterMap = j(setting("converter-map"));
// Mapping arrays oluştur ve cache'le
$cacheKey = "converter_map_data";
$mappings = Cache::remember($cacheKey, 3600, function() use ($converterMap) {
$termToRu = $termToEn = $enToRu = $ruToEn = $enToTerm = $ruToTerm = [];
if (is_array($converterMap)) {
foreach ($converterMap as $row) {
if (!empty($row['term']) && !empty($row['term_ru'])) {
$termToRu[$row['term']] = $row['term_ru'];
}
if (!empty($row['term']) && !empty($row['term_eng'])) {
$termToEn[$row['term']] = $row['term_eng'];
}
if (!empty($row['term_eng']) && !empty($row['term_ru'])) {
$enToRu[$row['term_eng']] = $row['term_ru'];
}
if (!empty($row['term_ru']) && !empty($row['term_eng'])) {
$ruToEn[$row['term_ru']] = $row['term_eng'];
}
if (!empty($row['term_eng']) && !empty($row['term'])) {
$enToTerm[$row['term_eng']] = $row['term'];
}
if (!empty($row['term_ru']) && !empty($row['term'])) {
$ruToTerm[$row['term_ru']] = $row['term'];
}
}
}
return [
'termToRu' => $termToRu,
'termToEn' => $termToEn,
'enToRu' => $enToRu,
'ruToEn' => $ruToEn,
'enToTerm' => $enToTerm,
'ruToTerm' => $ruToTerm
];
});
// Her bir mapping'i ayrı cache key'e kaydet
Cache::put('termToRu', $mappings['termToRu'], 3600);
Cache::put('termToEn', $mappings['termToEn'], 3600);
Cache::put('enToRu', $mappings['enToRu'], 3600);
Cache::put('ruToEn', $mappings['ruToEn'], 3600);
Cache::put('enToTerm', $mappings['enToTerm'], 3600);
Cache::put('ruToTerm', $mappings['ruToTerm'], 3600);
return $mappings;
}
function convertMap() {
$cacheKey = "converter_map_data";
// Önce cache'den okumayı dene
if (Cache::has($cacheKey)) {
$mappings = Cache::get($cacheKey);
// Cache'den okunan veri geçerli mi kontrol et
if (!empty($mappings) && is_array($mappings)) {
return $mappings;
}
}
// Cache yoksa veya geçersizse yeniden oluştur
$mappings = j(setting("converter-map"));
// Yeni veriyi cache'e kaydet
if (!empty($mappings) && is_array($mappings)) {
Cache::put($cacheKey, $mappings, 60);
}
return $mappings;
}
function convertRu($term) {
// Önce cache'de mapping var mı kontrol et
$converterMap = Cache::get('termToRu');
// Eğer cache'de yoksa, convertMapCache'i çağır
if (empty($converterMap)) {
convertMapCache();
$converterMap = Cache::get('termToRu');
}
if(isset($converterMap[$term])) {
return $converterMap[$term];
} else {
Log::info("convertRu not found", ['term' => $term]);
}
return $term;
}
function convertEn($term) {
// Önce cache'de mapping var mı kontrol et
$converterMap = Cache::get('termToEn');
// Eğer cache'de yoksa, convertMapCache'i çağır
if (empty($converterMap)) {
convertMapCache();
$converterMap = Cache::get('termToEn');
}
if(isset($converterMap[$term])) {
return $converterMap[$term];
}
return $term;
}
?>