editTagsSave: invalidate article cache
This commit is contained in:
parent
fde715c1f2
commit
bd3f2ade87
|
@ -4496,21 +4496,32 @@
|
||||||
|
|
||||||
function get_article_tags($link, $id, $owner_uid = 0) {
|
function get_article_tags($link, $id, $owner_uid = 0) {
|
||||||
|
|
||||||
|
global $memcache;
|
||||||
|
|
||||||
$a_id = db_escape_string($id);
|
$a_id = db_escape_string($id);
|
||||||
|
|
||||||
if (!$owner_uid) $owner_uid = $_SESSION["uid"];
|
if (!$owner_uid) $owner_uid = $_SESSION["uid"];
|
||||||
|
|
||||||
$tmp_result = db_query($link, "SELECT DISTINCT tag_name,
|
$query = "SELECT DISTINCT tag_name,
|
||||||
owner_uid as owner FROM
|
owner_uid as owner FROM
|
||||||
ttrss_tags WHERE post_int_id = (SELECT int_id FROM ttrss_user_entries WHERE
|
ttrss_tags WHERE post_int_id = (SELECT int_id FROM ttrss_user_entries WHERE
|
||||||
ref_id = '$a_id' AND owner_uid = '$owner_uid' LIMIT 1) ORDER BY tag_name");
|
ref_id = '$a_id' AND owner_uid = '$owner_uid' LIMIT 1) ORDER BY tag_name";
|
||||||
|
|
||||||
|
$obj_id = md5("TAGS:$owner_uid:$id");
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
||||||
|
if ($memcache && $obj = $memcache->get($obj_id)) {
|
||||||
|
$tags = $obj;
|
||||||
|
} else {
|
||||||
|
$tmp_result = db_query($link, $query);
|
||||||
|
|
||||||
while ($tmp_line = db_fetch_assoc($tmp_result)) {
|
while ($tmp_line = db_fetch_assoc($tmp_result)) {
|
||||||
array_push($tags, $tmp_line["tag_name"]);
|
array_push($tags, $tmp_line["tag_name"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($memcache) $memcache->add($obj_id, $tags, 0, 3600);
|
||||||
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6500,11 +6511,11 @@
|
||||||
$query = "SELECT * FROM ttrss_enclosures
|
$query = "SELECT * FROM ttrss_enclosures
|
||||||
WHERE post_id = '$id' AND content_url != ''";
|
WHERE post_id = '$id' AND content_url != ''";
|
||||||
|
|
||||||
$cache_id = md5($query);
|
$obj_id = md5("ENCLOSURES:$id");
|
||||||
|
|
||||||
$rv = array();
|
$rv = array();
|
||||||
|
|
||||||
if ($memcache && $obj = $memcache->get($cache_id)) {
|
if ($memcache && $obj = $memcache->get($obj_id)) {
|
||||||
$rv = $obj;
|
$rv = $obj;
|
||||||
} else {
|
} else {
|
||||||
$result = db_query($link, $query);
|
$result = db_query($link, $query);
|
||||||
|
@ -6513,7 +6524,7 @@
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
array_push($rv, $line);
|
array_push($rv, $line);
|
||||||
}
|
}
|
||||||
if ($memcache) $memcache->add($cache_id, $rv, 0, 3600);
|
if ($memcache) $memcache->add($obj_id, $rv, 0, 3600);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -440,6 +440,8 @@
|
||||||
|
|
||||||
if ($subop == "setArticleTags") {
|
if ($subop == "setArticleTags") {
|
||||||
|
|
||||||
|
global $memcache;
|
||||||
|
|
||||||
$id = db_escape_string($_REQUEST["id"]);
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
|
|
||||||
$tags_str = db_escape_string($_REQUEST["tags_str"]);
|
$tags_str = db_escape_string($_REQUEST["tags_str"]);
|
||||||
|
@ -480,6 +482,11 @@
|
||||||
|
|
||||||
db_query($link, "COMMIT");
|
db_query($link, "COMMIT");
|
||||||
|
|
||||||
|
if ($memcache) {
|
||||||
|
$obj_id = md5("TAGS:".$_SESSION["uid"].":$id");
|
||||||
|
$memcache->delete($obj_id);
|
||||||
|
}
|
||||||
|
|
||||||
$tags_str = format_tags_string(get_article_tags($link, $id), $id);
|
$tags_str = format_tags_string(get_article_tags($link, $id), $id);
|
||||||
|
|
||||||
print "<rpc-reply>
|
print "<rpc-reply>
|
||||||
|
|
|
@ -1500,6 +1500,8 @@ function editTagsSave() {
|
||||||
if (tags) {
|
if (tags) {
|
||||||
tags.innerHTML = tags_str.firstChild.nodeValue;
|
tags.innerHTML = tags_str.firstChild.nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache_invalidate(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue