]> git.mxchange.org Git - friendica.git/blob - include/cache.php
string update
[friendica.git] / include / cache.php
1 <?php
2         /**
3          *  cache api
4          */
5          
6         class Cache {
7                 public static function get($key){
8                         $r = q("SELECT `v` FROM `cache` WHERE `k`='%s'",
9                                 dbesc($key)
10                         );
11                         
12                         if (count($r)) return $r[0]['v'];
13                         return null;
14                 }
15                 
16                 public static function set($key,$value) {
17                         q("INSERT INTO `cache` VALUES ('%s','%s','%s')",
18                                 dbesc($key),
19                                 dbesc($value),
20                                 dbesc(datetime_convert()));
21                 }
22                 
23                 public static function clear(){
24                         q("DELETE FROM `cache` WHERE `updated` < '%s'",
25                                 dbesc(datetime_convert('UTC','UTC',"now - 30 days")));                  
26                 }
27                 
28         }
29