@@ -54,6 +54,11 @@ class Doviz
5454 */
5555 private $ cacheDriver = null ;
5656
57+ /**
58+ * CacheProvider için kullanılacak önbellek anahtarı
59+ *
60+ * @var string
61+ */
5762 private $ cacheKey = "Teknomavi_Tcmb_Doviz_Data " ;
5863
5964 /**
@@ -89,15 +94,19 @@ private function getTcmbData()
8994 }
9095 curl_close ($ ch );
9196 $ this ->data = $ this ->formatTcmbData ((array )simplexml_load_string ($ response ));
92- if ($ this ->data ['today ' ] == date ("d.m.Y " )) {
93- $ expire = strtotime ("Tomorrow 15:30 " );
97+ $ timezone = new \DateTimeZone ('Europe/Istanbul ' );
98+ $ now = new \DateTime ("now " , $ timezone );
99+ if ($ this ->data ['today ' ] == $ now ->format ("d.m.Y " )) {
100+ $ expire = "Tomorrow 15:30 " ;
94101 } else {
95- $ expire = strtotime ( "Today 15:30 " ) ;
102+ $ expire = "Today 15:30 " ;
96103 }
97- $ this ->data ['expire ' ] = $ expire ;
104+ $ expireDate = new \DateTime ($ expire , $ timezone );
105+ $ this ->data ['expire ' ] = $ expireDate ->getTimestamp ();
98106 if (!is_null ($ this ->cacheDriver )) {
99- $ lifetime = $ expire - time ();
100- $ this ->cacheDriver ->save ($ this ->cacheKey , $ this ->data , $ lifetime > 0 ? $ lifetime : 30 * 60 );
107+ $ lifetime = $ expire - $ now ->getTimestamp ();
108+ // Eğer dosyanın geçerlilik süresi bitmişse veriyi sadece 5 dakika önbellekte tutuyoruz.
109+ $ this ->cacheDriver ->save ($ this ->cacheKey , $ this ->data , $ lifetime > 0 ? $ lifetime : 300 );
101110 }
102111 }
103112
0 commit comments