Added apcu caching method and bump
This commit is contained in:
parent
faf1dcee51
commit
d273b35e53
25
app/Cache/ApcuCache.php
Normal file
25
app/Cache/ApcuCache.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Cache;
|
||||||
|
|
||||||
|
use TikScraper\Interfaces\CacheInterface;
|
||||||
|
|
||||||
|
class ApcuCache implements CacheInterface {
|
||||||
|
function __construct() {
|
||||||
|
if (!(extension_loaded('apcu') && apcu_enabled())) {
|
||||||
|
throw new \Exception('APCu not enabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(string $cache_key): ?object {
|
||||||
|
$data = apcu_fetch($cache_key);
|
||||||
|
return $data !== false ? json_decode($data) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exists(string $cache_key): bool {
|
||||||
|
return apcu_exists($cache_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set(string $cache_key, string $data, $timeout = 3600): void {
|
||||||
|
apcu_store($cache_key, $data, $timeout);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,5 +3,6 @@ namespace App\Constants;
|
||||||
|
|
||||||
abstract class CacheMethods {
|
abstract class CacheMethods {
|
||||||
const JSON = 'json';
|
const JSON = 'json';
|
||||||
|
const APCU = 'apcu';
|
||||||
const REDIS = 'redis';
|
const REDIS = 'redis';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Cache\ApcuCache;
|
||||||
use App\Cache\JSONCache;
|
use App\Cache\JSONCache;
|
||||||
use App\Cache\RedisCache;
|
use App\Cache\RedisCache;
|
||||||
use App\Constants\CacheMethods;
|
use App\Constants\CacheMethods;
|
||||||
|
@ -138,6 +139,9 @@ class Wrappers {
|
||||||
case CacheMethods::JSON:
|
case CacheMethods::JSON:
|
||||||
$cacheEngine = new JSONCache();
|
$cacheEngine = new JSONCache();
|
||||||
break;
|
break;
|
||||||
|
case CacheMethods::APCU:
|
||||||
|
$cacheEngine = new ApcuCache();
|
||||||
|
break;
|
||||||
case CacheMethods::REDIS:
|
case CacheMethods::REDIS:
|
||||||
if (!(isset($_ENV['REDIS_URL']) || isset($_ENV['REDIS_HOST'], $_ENV['REDIS_PORT']))) {
|
if (!(isset($_ENV['REDIS_URL']) || isset($_ENV['REDIS_HOST'], $_ENV['REDIS_PORT']))) {
|
||||||
throw new \Exception('You need to set REDIS_URL or REDIS_HOST and REDIS_PORT to use Redis Cache!');
|
throw new \Exception('You need to set REDIS_URL or REDIS_HOST and REDIS_PORT to use Redis Cache!');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "pablouser1/proxitok",
|
"name": "pablouser1/proxitok",
|
||||||
"description": "An alternative frontend for TikTok",
|
"description": "An alternative frontend for TikTok",
|
||||||
"version": "2.4.4.1",
|
"version": "2.4.4.2",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
14
composer.lock
generated
14
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "f9cec7d0ed07b8f1d6db885ceefd3226",
|
"content-hash": "c6c6c5ecb586c3f4701ffb57ccf385e4",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bramus/router",
|
"name": "bramus/router",
|
||||||
|
@ -263,16 +263,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pablouser1/tikscraper",
|
"name": "pablouser1/tikscraper",
|
||||||
"version": "v2.3.3.3",
|
"version": "v2.3.3.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pablouser1/TikScraperPHP.git",
|
"url": "https://github.com/pablouser1/TikScraperPHP.git",
|
||||||
"reference": "a870b234fbb10f2bafea2130510f463b03069dd8"
|
"reference": "065cd740373f6f423d366d73ea94437041ec85cd"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/a870b234fbb10f2bafea2130510f463b03069dd8",
|
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/065cd740373f6f423d366d73ea94437041ec85cd",
|
||||||
"reference": "a870b234fbb10f2bafea2130510f463b03069dd8",
|
"reference": "065cd740373f6f423d366d73ea94437041ec85cd",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -305,9 +305,9 @@
|
||||||
"description": "Get data from TikTok API",
|
"description": "Get data from TikTok API",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/pablouser1/TikScraperPHP/issues",
|
"issues": "https://github.com/pablouser1/TikScraperPHP/issues",
|
||||||
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.3.3"
|
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.3.3.4"
|
||||||
},
|
},
|
||||||
"time": "2023-01-25T14:15:59+00:00"
|
"time": "2023-01-25T14:17:57+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "php-webdriver/webdriver",
|
"name": "php-webdriver/webdriver",
|
||||||
|
|
Loading…
Reference in a new issue