We now use memcache if configured and installed.

This commit is contained in:
Michael Vogel 2016-10-23 21:59:40 +00:00
commit ee5ada6991
13 changed files with 339 additions and 130 deletions

View file

@ -788,7 +788,6 @@ function item_post(&$a) {
} else
$post_id = 0;
q("COMMIT;");
q("START TRANSACTION;");
$r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,
@ -990,12 +989,14 @@ function item_post(&$a) {
create_tags_from_item($post_id);
create_files_from_item($post_id);
q("COMMIT");
if ($post_id == $parent)
if ($post_id == $parent) {
add_thread($post_id);
else {
q("COMMIT");
add_shadow_thread($post_id);
} else {
update_thread($parent, true);
q("COMMIT");
// Insert an item entry for UID=0 for global entries
// We have to remove or change some data before that,

View file

@ -53,12 +53,18 @@ function photos_init(&$a) {
$sql_extra = permissions_sql($a->data['user']['uid']);
$albums = qu("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` USE INDEX (`uid_album_created`) WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `album` ORDER BY `created` DESC",
intval($a->data['user']['uid']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos'))
);
$albums = Cache::get("photos-albums:".$a->data['user']['uid']);
if (is_null($albums)) {
/// @todo This query needs to be renewed. It is really slow
// At this time we just store the data in the cache
$albums = qu("SELECT count(distinct `resource-id`) AS `total`, `album` FROM `photo` USE INDEX (`uid_album_created`) WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `album` ORDER BY `created` DESC",
intval($a->data['user']['uid']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos'))
);
Cache::set("photos-albums:".$a->data['user']['uid'], $albums, CACHE_FIVE_MINUTES);
}
$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);

View file

@ -282,16 +282,20 @@ function profile_content(&$a, $update = 0) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`
FROM `thread` FORCE INDEX (`uid_created`) INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
$sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
and `thread`.`moderated` = 0
AND `thread`.`wall` = 1
$sql_extra $sql_extra2
ORDER BY `thread`.`created` DESC $pager_sql ",
intval($a->profile['profile_uid'])
FROM `thread`
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
$sql_post_table
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
WHERE `thread`.`uid` = %d AND `thread`.`visible`
AND `thread`.`contact-id` = %d
AND NOT `thread`.`deleted`
AND NOT `thread`.`moderated`
AND `thread`.`wall`
$sql_extra $sql_extra2
ORDER BY `thread`.`created` DESC $pager_sql",
intval($a->profile['profile_uid']),
intval($a->profile['contact_id'])
);
}