From ca1b27d10f70e41f37bb93f5ddf606f6f1300152 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 17 Jul 2018 20:34:59 -0400 Subject: [PATCH] [mastodoncustomenojis] Add shorter ttl for API call fail - Add cache bypass through system.ignore_cache --- mastodoncustomemojis/mastodoncustomemojis.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index da9bbf7f..71b6db5c 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -12,6 +12,7 @@ use Friendica\App; use Friendica\Content\Smilies; use Friendica\Core\Addon; use Friendica\Core\Cache; +use Friendica\Core\Config; use Friendica\Core\Protocol; use Friendica\Util\Network; @@ -73,7 +74,7 @@ function mastodoncustomemojis_get_custom_emojis_for_author($author_link) $cache_key = 'mastodoncustomemojis:' . $api_base_url; $emojis = Cache::get($cache_key); - if (empty($emojis)) { + if (empty($emojis['texts']) || Config::get('system', 'ignore_cache')) { // Reset the emojis array $emojis = $return; @@ -90,9 +91,13 @@ function mastodoncustomemojis_get_custom_emojis_for_author($author_link) $emojis['icons'][] = ':' . $emoji['shortcode'] . ':'; } } + + $ttl = Cache::WEEK; + } else { + $ttl = Cache::HALF_HOUR; } - Cache::set($cache_key, $emojis, Cache::WEEK); + Cache::set($cache_key, $emojis, $ttl); $return = $emojis; } -- 2.39.5