7 public static function get($key){
8 $r = q("SELECT `v` FROM `cache` WHERE `k`='%s' limit 1",
12 if (count($r)) return $r[0]['v'];
16 public static function set($key,$value) {
18 q("REPLACE INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
21 dbesc(datetime_convert()));
27 * Leaving this legacy code temporaily to see how REPLACE fares
28 * as opposed to non-atomic checks when faced with fast moving key duplication.
29 * As a MySQL extension it isn't portable, but we're not yet very portable.
33 * $r = q("SELECT * FROM `cache` WHERE `k`='%s' limit 1",
37 * q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s' limit 1",
39 * dbesc(datetime_convert()),
43 * q("INSERT INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
46 * dbesc(datetime_convert()));
52 public static function clear(){
53 q("DELETE FROM `cache` WHERE `updated` < '%s'",
54 dbesc(datetime_convert('UTC','UTC',"now - 30 days")));