mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-23 15:06:53 +00:00
Merge b5cb091995
into 9c8a9d1d1d
This commit is contained in:
commit
8617e95ed6
@ -1,14 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Cache with file system
|
* Cache with file system
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class FileCache extends CacheAbstract{
|
class FileCache extends CacheAbstract{
|
||||||
protected $cacheDirCreated; // boolean to avoid always chck dir cache existance
|
protected
|
||||||
|
$cacheDirCreated, // boolean to avoid always chck dir cache existance
|
||||||
|
$hash_algo = 'sha1' // hash method for cache key
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
public function loadData(){
|
public function loadData(){
|
||||||
$this->isPrepareCache();
|
$this->isPrepareCache();
|
||||||
|
|
||||||
$datas = json_decode(file_get_contents($this->getCacheFile()),true);
|
$datas = include( $this->getCacheFile() );
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach($datas as $aData){
|
foreach($datas as $aData){
|
||||||
$item = new \Item();
|
$item = new \Item();
|
||||||
@ -24,7 +30,7 @@ class FileCache extends CacheAbstract{
|
|||||||
public function saveData($datas){
|
public function saveData($datas){
|
||||||
$this->isPrepareCache();
|
$this->isPrepareCache();
|
||||||
|
|
||||||
file_put_contents($this->getCacheFile(), json_encode($datas));
|
file_put_contents($this->getCacheFile(), '<?php return '.var_export($datas).';' );
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -87,6 +93,6 @@ class FileCache extends CacheAbstract{
|
|||||||
$this->isPrepareCache();
|
$this->isPrepareCache();
|
||||||
|
|
||||||
$stringToEncode = $_SERVER['REQUEST_URI'] . http_build_query($this->param);
|
$stringToEncode = $_SERVER['REQUEST_URI'] . http_build_query($this->param);
|
||||||
return hash('sha1', $stringToEncode) . '.cache';
|
return hash($this->hash_algo , $stringToEncode) . '.cache.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user