aboutsummaryrefslogtreecommitdiffstats
path: root/include/cache.php
diff options
context:
space:
mode:
authorSimon L'nu <simon.lnu@gmail.com>2012-05-03 00:25:56 -0400
committerSimon L'nu <simon.lnu@gmail.com>2012-05-03 00:25:56 -0400
commit0446766f0407b45c78031ad9e5029cc9218b025e (patch)
tree030c81fee9826ce80c0bd488f06fd469d2a6afa9 /include/cache.php
parent02dc116a9c646ea5683b8df199a7ff492ae6cfcb (diff)
parentff2ddc319d4307e56a1bf48f51f8f948fe0736ca (diff)
downloadvolse-hubzilla-0446766f0407b45c78031ad9e5029cc9218b025e.tar.gz
volse-hubzilla-0446766f0407b45c78031ad9e5029cc9218b025e.tar.bz2
volse-hubzilla-0446766f0407b45c78031ad9e5029cc9218b025e.zip
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
* remotes/upstream/master: diabook-theme: small fix diabook-theme: made boxes at right_aside sortable use cid rather than uid in perms Modify events_post() in mod/events.php to set the `private` field to true when an event is shared with specific people. This is necessary to have event posts show correctly in Diaspora if an event is created visible only to self, but modified later to be visible to others. use mysql replace on cache items fixing common friends rev update Moved Meta Viewport from global head.tpl to diabook's header * master:
Diffstat (limited to 'include/cache.php')
-rw-r--r--include/cache.php42
1 files changed, 30 insertions, 12 deletions
diff --git a/include/cache.php b/include/cache.php
index 3c8a3f713..360c4acbd 100644
--- a/include/cache.php
+++ b/include/cache.php
@@ -14,22 +14,40 @@
}
public static function set($key,$value) {
- $r = q("SELECT * FROM `cache` WHERE `k`='%s' limit 1",
- dbesc($key)
- );
- if(count($r)) {
- q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s' limit 1",
- dbesc($value),
- dbesc(datetime_convert()),
- dbesc($key));
- }
- else {
- q("INSERT INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
+
+ q("REPLACE INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
dbesc($key),
dbesc($value),
dbesc(datetime_convert()));
- }
}
+
+
+/*
+ *
+ * Leaving this legacy code temporaily to see how REPLACE fares
+ * as opposed to non-atomic checks when faced with fast moving key duplication.
+ * As a MySQL extension it isn't portable, but we're not yet very portable.
+ */
+
+/*
+ * $r = q("SELECT * FROM `cache` WHERE `k`='%s' limit 1",
+ * dbesc($key)
+ * );
+ * if(count($r)) {
+ * q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s' limit 1",
+ * dbesc($value),
+ * dbesc(datetime_convert()),
+ * dbesc($key));
+ * }
+ * else {
+ * q("INSERT INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
+ * dbesc($key),
+ * dbesc($value),
+ * dbesc(datetime_convert()));
+ * }
+ * }
+ */
+
public static function clear(){
q("DELETE FROM `cache` WHERE `updated` < '%s'",