refactor(cache): extract and encapsulate cache expiration logic (#3547)

* refactor(cache): extract and encapsulate cache expiration logic

* fix: logic bug in getSimpleHTMLDOMCached

* fix: silly me, index should of course be on the key column

* silly me again, PRIMARY keys get index by default lol

* comment out the delete portion in loadData

* remove a few log statements

* tweak twitter cache timeout
This commit is contained in:
Dag 2023-07-19 05:05:49 +02:00 committed by GitHub
parent 087e790ec1
commit 6254b8593e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 124 additions and 137 deletions

View file

@ -7,7 +7,7 @@ class TwitterBridge extends BridgeAbstract
const API_URI = 'https://api.twitter.com';
const GUEST_TOKEN_USES = 100;
const GUEST_TOKEN_EXPIRY = 10800; // 3hrs
const CACHE_TIMEOUT = 300; // 5min
const CACHE_TIMEOUT = 60 * 15; // 15min
const DESCRIPTION = 'returns tweets';
const MAINTAINER = 'arnd-s';
const PARAMETERS = [
@ -224,10 +224,6 @@ EOD
switch ($this->queriedContext) {
case 'By username':
$cache = RssBridge::getCache();
$cache->setScope('twitter');
$cache->setKey(['cache']);
// todo: inspect mtime instead of purging with 3h
$cache->purgeCache(60 * 60 * 3);
$api = new TwitterClient($cache);
$screenName = $this->getInput('u');