first commit
This commit is contained in:
14
class/smarty_plugins/function.get_and_cache.php
Normal file
14
class/smarty_plugins/function.get_and_cache.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
function smarty_function_get_and_cache($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = 'get_and_cache_'.md5(join('-', $params));
|
||||
$data = getCache($key, $found);
|
||||
|
||||
if (!$found) {
|
||||
$data = json_decode(file_get_contents($params['url']), true);
|
||||
setCache($key, $data, $params['ttl'] ?? 7200);
|
||||
}
|
||||
|
||||
$template->assign($params['assign'], $data);
|
||||
}
|
||||
Reference in New Issue
Block a user