]> git.mxchange.org Git - friendica.git/commitdiff
Move Cache::set() to DI::cache()->set()
authornupplaPhil <admin@philipp.info>
Mon, 6 Jan 2020 23:41:20 +0000 (00:41 +0100)
committernupplaPhil <admin@philipp.info>
Mon, 6 Jan 2020 23:41:20 +0000 (00:41 +0100)
16 files changed:
mod/ping.php
mod/poco.php
src/Content/OEmbed.php
src/Content/Text/BBCode.php
src/Core/Cache.php
src/Model/Photo.php
src/Model/Profile.php
src/Model/Term.php
src/Module/Search/Index.php
src/Network/Probe.php
src/Protocol/ActivityPub/Transmitter.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Util/Images.php
src/Util/JsonLD.php
src/Worker/SearchDirectory.php

index c76780f69744c7cf11c0f0eaff2ea7a65fe0ed05..9593d6ed26df2c6e5964bf8de60ac2605c590eeb 100644 (file)
@@ -208,7 +208,7 @@ function ping_init(App $a)
                                DBA::escape(DateTimeFormat::utcNow())
                        );
                        if (DBA::isResult($ev)) {
-                               Cache::set($cachekey, $ev, Cache::HOUR);
+                               DI::cache()->set($cachekey, $ev, Cache::HOUR);
                        }
                }
 
index 2ed871285b76586b38e30eb63def4c6d49816cb9..cbee264585dbd71e95a09e4d8a1f5b9f064c1866 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
@@ -258,7 +259,7 @@ function poco_init(App $a) {
                                $about = Cache::get("about:" . $contact['updated'] . ":" . $contact['nurl']);
                                if (is_null($about)) {
                                        $about = BBCode::convert($contact['about'], false);
-                                       Cache::set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
+                                       DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
                                }
 
                                // Non connected persons can only see the keywords of a Diaspora account
index 95fd6530b68e9a34b981d25daf6556c3e0f610ff..51918283e0c2e48b86ac44114ae22b7af14a27cd 100644 (file)
@@ -125,7 +125,7 @@ class OEmbed
                                $cache_ttl = Cache::FIVE_MINUTES;
                        }
 
-                       Cache::set($cache_key, $json_string, $cache_ttl);
+                       DI::cache()->set($cache_key, $json_string, $cache_ttl);
                }
 
                if ($oembed->type == 'error') {
index 51fa08ad3d3afe9fbdb06c580b8384c267eff0f6..1489ed232f422fedc1da48493d9e2e1aef6e3491 100644 (file)
@@ -1112,7 +1112,7 @@ class BBCode
                                        }
                                }
                        }
-                       Cache::set($cache_key, $text);
+                       DI::cache()->set($cache_key, $text);
                }
 
                return $text;
@@ -1194,7 +1194,7 @@ class BBCode
                                }
                        }
                }
-               Cache::set($cache_key, $text);
+               DI::cache()->set($cache_key, $text);
 
                return $text;
        }
index 0328cf84cb186b7f5f07d359bc092ce30a626ecf..410f9fea188b6111efc545b2fa58f503547d2e03 100644 (file)
@@ -43,21 +43,4 @@ class Cache
        {
                return DI::cache()->get($key);
        }
-
-       /**
-        * @brief Put data in the cache according to the key
-        *
-        * The input $value can have multiple formats.
-        *
-        * @param string  $key      The key to the cached data
-        * @param mixed   $value    The value that is about to be stored
-        * @param integer $duration The cache lifespan
-        *
-        * @return bool
-        * @throws \Exception
-        */
-       public static function set($key, $value, $duration = CacheClass::MONTH)
-       {
-               return DI::cache()->set($key, $value, $duration);
-       }
 }
index c4dbf2b30a1f53eda14d089cf2e8eb6da2babfad..0d05d81d0d7024e8dfee84c3320e6d087a9b846b 100644 (file)
@@ -569,7 +569,7 @@ class Photo
                                        DBA::escape(L10n::t("Contact Photos"))
                                );
                        }
-                       Cache::set($key, $albums, Cache::DAY);
+                       DI::cache()->set($key, $albums, Cache::DAY);
                }
                return $albums;
        }
@@ -582,7 +582,7 @@ class Photo
        public static function clearAlbumCache($uid)
        {
                $key = "photo_albums:".$uid.":".local_user().":".remote_user();
-               Cache::set($key, null, Cache::DAY);
+               DI::cache()->set($key, null, Cache::DAY);
        }
 
        /**
index d7cc906fdbc5a5b49b5707e5a6642df00b4cf4f0..a5619c999bd1a77f7238cee6f3b8f9dfdc3ecec2 100644 (file)
@@ -608,7 +608,7 @@ class Profile
                        );
                        if (DBA::isResult($s)) {
                                $r = DBA::toArray($s);
-                               Cache::set($cachekey, $r, Cache::HOUR);
+                               DI::cache()->set($cachekey, $r, Cache::HOUR);
                        }
                }
 
@@ -1070,7 +1070,7 @@ class Profile
                        Logger::log('URL ' . $my_url . ' already tried to authenticate.', Logger::DEBUG);
                        return;
                } else {
-                       Cache::set($cachekey, true, Cache::MINUTE);
+                       DI::cache()->set($cachekey, true, Cache::MINUTE);
                }
 
                Logger::log('Not authenticated. Invoking reverse magic-auth for ' . $my_url, Logger::DEBUG);
index 08a02ff07564d662c120624adff4a9730bed7212..4eca9639ff9c590bb8ee45a44963c87743b5347a 100644 (file)
@@ -84,7 +84,7 @@ class Term
 
                        if (DBA::isResult($tagsStmt)) {
                                $tags = DBA::toArray($tagsStmt);
-                               Cache::set('global_trending_tags', $tags, Cache::HOUR);
+                               DI::cache()->set('global_trending_tags', $tags, Cache::HOUR);
                        }
                }
 
@@ -129,7 +129,7 @@ class Term
 
                        if (DBA::isResult($tagsStmt)) {
                                $tags = DBA::toArray($tagsStmt);
-                               Cache::set('local_trending_tags', $tags, Cache::HOUR);
+                               DI::cache()->set('local_trending_tags', $tags, Cache::HOUR);
                        }
                }
 
index 247ac5988c2bd52e34fc76d7fb83928a2b3b493f..776b3fced992873fa5b2b9d886ab551b4cec4f68 100644 (file)
@@ -59,9 +59,9 @@ class Index extends BaseSearchModule
                                if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
                                        throw new HTTPException\TooManyRequestsException(L10n::t('Only one search per minute is permitted for not logged in users.'));
                                }
-                               Cache::set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => $resultdata->accesses + 1]), CacheClass::HOUR);
+                               DI::cache()->set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => $resultdata->accesses + 1]), CacheClass::HOUR);
                        } else {
-                               Cache::set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => 1]), CacheClass::HOUR);
+                               DI::cache()->set('remote_search:' . $remote, json_encode(['time' => time(), 'accesses' => 1]), CacheClass::HOUR);
                        }
                }
 
index 122df70ce746780ff68885005aeb51b8cff74c84..c3279cd9d24ea2fe8e863750d224c135f7e53ba5 100644 (file)
@@ -409,7 +409,7 @@ class Probe
 
                // Only store into the cache if the value seems to be valid
                if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
-                       Cache::set('Probe::uri:' . $network . ':' . $uri, $data, Cache::DAY);
+                       DI::cache()->set('Probe::uri:' . $network . ':' . $uri, $data, Cache::DAY);
                }
 
                return $data;
index 6a512323cf517656751a10dc440df4f9cb9d48fc..9a2b584fe3f3dcd303e26e6c40f3ab1f899481c5 100644 (file)
@@ -827,7 +827,7 @@ class Transmitter
 
                $data = ActivityPub\Transmitter::createActivityFromItem($item_id);
 
-               Cache::set($cachekey, $data, Cache::QUARTER_HOUR);
+               DI::cache()->set($cachekey, $data, Cache::QUARTER_HOUR);
                return $data;
        }
 
index a683a23514b35a349c38221e31e685ff73cb0cb7..2d94e96c22c919a78f9ee65c7373e77a7f83f5a5 100644 (file)
@@ -3272,7 +3272,7 @@ class Diaspora
                Logger::log("Send participation for ".$item["guid"]." by ".$author, Logger::DEBUG);
 
                // It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item
-               Cache::set($cachekey, $item["guid"], Cache::QUARTER_HOUR);
+               DI::cache()->set($cachekey, $item["guid"], Cache::QUARTER_HOUR);
 
                return self::buildAndTransmit($owner, $contact, "participation", $message);
        }
@@ -3628,7 +3628,7 @@ class Diaspora
 
                $msg = ["type" => $type, "message" => $message];
 
-               Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
+               DI::cache()->set($cachekey, $msg, Cache::QUARTER_HOUR);
 
                return $msg;
        }
@@ -3798,7 +3798,7 @@ class Diaspora
                        $comment['thread_parent_guid'] = $thread_parent_item['guid'];
                }
 
-               Cache::set($cachekey, $comment, Cache::QUARTER_HOUR);
+               DI::cache()->set($cachekey, $comment, Cache::QUARTER_HOUR);
 
                return($comment);
        }
index 21659a6036ae79f696a1b6dbe13358ecaa438895..38936762e0a69037e779537c5d883c0c605b8480 100644 (file)
@@ -2246,7 +2246,7 @@ class OStatus
                $feeddata = trim($doc->saveXML());
 
                $msg = ['feed' => $feeddata, 'last_update' => $last_update];
-               Cache::set($cachekey, $msg, Cache::QUARTER_HOUR);
+               DI::cache()->set($cachekey, $msg, Cache::QUARTER_HOUR);
 
                Logger::log('Feed duration: ' . number_format(microtime(true) - $stamp, 3) . ' - ' . $owner_nick . ' - ' . $filter . ' - ' . $previous_created, Logger::DEBUG);
 
index e19304bba1e5d42e8f7a426a2467b3fc387dfa8c..b557d891d88ecdf503ae554d6704fec562b88d6f 100644 (file)
@@ -130,7 +130,7 @@ class Images
                if (empty($data) || !is_array($data)) {
                        $data = self::getInfoFromURL($url);
 
-                       Cache::set($url, $data);
+                       DI::cache()->set($url, $data);
                }
 
                return $data;
index 926fa1437d46aa1cb4efac0c8d79fbdaf1527d2d..598898c0e8b3e6afad9901771bac061901def698 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Util;
 use Friendica\Core\Cache;
 use Friendica\Core\Logger;
 use Exception;
+use Friendica\DI;
 
 /**
  * @brief This class contain methods to work with JsonLD data
@@ -45,7 +46,7 @@ class JsonLD
                }
 
                $data = jsonld_default_document_loader($url);
-               Cache::set('documentLoader:' . $url, $data, Cache::DAY);
+               DI::cache()->set('documentLoader:' . $url, $data, Cache::DAY);
                return $data;
        }
 
index 4503f21ca6006968da6e5d37c4d113091745c9de..fcac721dfdaeb5e539e376af1b07385e4cd62e00 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Search;
 use Friendica\Database\DBA;
+use Friendica\DI;
 use Friendica\Model\GContact;
 use Friendica\Model\GServer;
 use Friendica\Network\Probe;
@@ -80,6 +81,6 @@ class SearchDirectory
                                }
                        }
                }
-               Cache::set('SearchDirectory:' . $search, time(), Cache::DAY);
+               DI::cache()->set('SearchDirectory:' . $search, time(), Cache::DAY);
        }
 }