キャッシュシステム (#26) +一部修正

This commit is contained in:
2026-04-30 19:50:11 +09:00
parent d3e04ace96
commit cf8545c5d8
5 changed files with 275 additions and 217 deletions

View File

@@ -99,6 +99,7 @@ class Op {
$tmpl->assign('data', $data->data); $tmpl->assign('data', $data->data);
$tmpl->addCss('table'); $tmpl->addCss('table');
$tmpl->addCss('openprovider');
$tmpl->render('listcustomers'); $tmpl->render('listcustomers');
exit(); exit();
@@ -115,7 +116,11 @@ class Op {
'additional_data' => [ 'additional_data' => [
'company_registration_number' => $_POST['company_registration_number'] ?? '', 'company_registration_number' => $_POST['company_registration_number'] ?? '',
'company_url' => $_POST['company_url'] ?? '', 'company_url' => $_POST['company_url'] ?? '',
'birth_date' => $_POST['birth_year'] !== '' && $_POST['birth_month'] !== '' && $_POST['birth_day'] !== '' ? $_POST['birth_year'].'-'.$_POST['birth_month'].'-'.$_POST['birth_day'] : '', 'birth_date' => (isset($_POST['birth_year']) && $_POST['birth_year'] !== '')
&& (isset($_POST['birth_month']) && $_POST['birth_month'] !== '')
&& (isset($_POST['birth_day']) && $_POST['birth_day'] !== '')
? $_POST['birth_year'].'-'.$_POST['birth_month'].'-'.$_POST['birth_day']
: '',
'trading_name' => $_POST['company_name'] ?? '', 'trading_name' => $_POST['company_name'] ?? '',
], ],
'address' => [ 'address' => [
@@ -142,7 +147,10 @@ class Op {
'locale' => 'ja_JP', 'locale' => 'ja_JP',
'name' => [ 'name' => [
'first_name' => $_POST['first_name'] ?? '', 'first_name' => $_POST['first_name'] ?? '',
'full_name' => $_POST['first_name'] !== '' && $_POST['last_name'] !== '' ? $_POST['first_name'].' '.$_POST['last_name'] : '', 'full_name' => (isset($_POST['first_name']) && $_POST['first_name'] !== '')
&& (isset($_POST['last_name']) && $_POST['last_name'] !== '')
? $_POST['first_name'].' '.$_POST['last_name']
: '',
'last_name' => $_POST['last_name'] ?? '', 'last_name' => $_POST['last_name'] ?? '',
], ],
'phone' => [ 'phone' => [

118
src/Std/Lib/Cache.php Normal file
View File

@@ -0,0 +1,118 @@
<?php
/*************************************************************
# 076 License
Copyright (c) テクニカル諏訪子
Permission is hereby granted to any person obtaining a copy of the software
Little Beast (the "Software") to use, modify, merge, copy, publish, distribute,
sublicense, and/or sell copies of the Software, subject to the following conditions:
1. **Origin Attribution**:
- You must not misrepresent the origin of the Software; you must not claim
you created the original Software.
- If the Software is used in a product, you must either:
a. Provide clear attribution in the product's documentation, user interface,
or other visible areas, **OR**
b. Pay the original developers a fee they specify in writing.
2. **Usage Restriction**:
- The Software, or any derivative works, dependencies, or libraries
incorporating it, must not be used for censorship or to suppress freedom of
speech, expression, or creativity. Prohibited uses include, but are not
limited to:
- Censorship of so-called "hate speech", visuals, non-mainstream opinions,
ideas, or objective reality.
- Tools or systems designed to restrict access to information or
artistic works.
3. **Notice Preservation**:
- This license and the above copyright notice must remain intact in all copies
of the source code.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Std\Lib;
use Result;
/**
* キャッシュ
*/
class Cache {
private string $dataDir;
protected int $dataDuration = 1800; // 30分
public function __construct(string $dataDir) {
$this->dataDir = $dataDir;
}
/**
* キャッシュの作成
*
* @param string $type キャッシュ類login、domainlist等
* @param array $data 保存するデータ
* @return Result
*/
public function set(string $type, array $data): Result {
if (!file_exists($this->dataDir)) {
if (!mkdir($this->dataDir, 0755))
return Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。');
}
$data['lifespan'] = time();
$json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if (file_put_contents("{$this->dataDir}{$type}.json", $json) === false) return Result::Error('エラー:ユーザーデータの保存に失敗。');
return Result::Success();
}
/**
* キャッシュから受け取り
*
* @param string $type キャッシュ類login、domainlist等
* @return array
*/
public function get(string $type): array {
if (!file_exists("{$this->dataDir}{$type}.json")) return [];
$content = file_get_contents("{$this->dataDir}{$type}.json");
if ($content === false) return [];
$data = json_decode($content, true);
if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) return [];
return $data;
}
/**
* キャッシュを破壊する
*
* @param string $name キャッシュのファイル名
* @return Result
*/
public function murder(string $name): Result {
if (!file_exists("{$this->dataDir}{$name}.json")) return Result::Error('キャッシュファイルが存在しない。');
if (!unlink("{$this->dataDir}{$name}.json")) return Result::Error('キャッシュファイルの削除に失敗。');
return Result::Success();
}
/**
* キャッシュ有効期限の確認
*
* @param array $cache
* @param mixed $data デフォルトnull
* @param string $dataPoint デフォルトquery
* @return bool
*/
public function validate(array $cache, mixed $data = null, string $dataPoint = 'query'): bool {
if (NULL === $data) return (!empty($cache) && (isset($cache['lifespan']) && time() < ($cache['lifespan'] + $this->dataDuration)));
else return (!empty($cache)
&& (isset($cache[$dataPoint])
&& $cache[$dataPoint] === $data)
&& (isset($cache['lifespan']) && time() < ($cache['lifespan'] + $this->dataDuration)));
}
}

View File

@@ -37,14 +37,15 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
namespace Std\Lib; namespace Std\Lib;
use Std\Lib\Cache;
use Std\Lib\Curl; use Std\Lib\Curl;
use Result; use Result;
class Openprovider { class Openprovider {
protected string $dataDir = ROOT."/data/cache/openprovider/"; protected string $cacheDir = ROOT."/data/cache/openprovider/";
protected int $tokenDuration = 172800; // 48時間 protected int $tokenDuration = 172800; // 48時間
protected int $dataDuration = 1800; // 30分
private Cache $cache;
private string $user = ''; private string $user = '';
private string $pass = ''; private string $pass = '';
private string $token = ''; private string $token = '';
@@ -59,6 +60,7 @@ class Openprovider {
$this->user = OPENPROVIDER['username']; $this->user = OPENPROVIDER['username'];
$this->pass = OPENPROVIDER['password']; $this->pass = OPENPROVIDER['password'];
$this->ip = OPENPROVIDER['ip']; $this->ip = OPENPROVIDER['ip'];
$this->cache = new Cache($this->cacheDir);
} }
/** /**
@@ -70,7 +72,7 @@ class Openprovider {
public function login(): Result { public function login(): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'login'; $cacheName = 'login';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if (time() < ($this->lastAuth + $this->tokenDuration)) { if (time() < ($this->lastAuth + $this->tokenDuration)) {
$this->token = $cache['data']['token']; $this->token = $cache['data']['token'];
$this->lastAuth = $cache['last_auth']; $this->lastAuth = $cache['last_auth'];
@@ -110,7 +112,7 @@ class Openprovider {
$this->token = $res['data']['token']; $this->token = $res['data']['token'];
$this->lastAuth = time(); $this->lastAuth = time();
$res['last_auth'] = $this->lastAuth; $res['last_auth'] = $this->lastAuth;
$this->setCache($cacheName, $res); $this->cache->set($cacheName, $res);
return Result::Success('', $res); return Result::Success('', $res);
} }
@@ -150,14 +152,14 @@ class Openprovider {
*/ */
public function listDomains(array $query = []): Result { public function listDomains(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listdomains' $cacheName = 'listdomains';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
$curl = $this->setupCurl('/domains'); $curl = $this->setupCurl('/domains');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res['data']['results'])) { if (isset($res['data']['results'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res['data']['results']); return Result::Success('', $res['data']['results']);
} }
@@ -271,14 +273,14 @@ class Openprovider {
if (isset($query['domain.extension'])) $ext = $query['domain.extension']; if (isset($query['domain.extension'])) $ext = $query['domain.extension'];
$cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata'; $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
$uri = "/domains/additional-data?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = "/domains/additional-data?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -302,14 +304,14 @@ class Openprovider {
if (isset($query['domain.extension'])) $ext = $query['domain.extension']; if (isset($query['domain.extension'])) $ext = $query['domain.extension'];
$cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata'; $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
$uri = "/domains/additional-data/customers?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = "/domains/additional-data/customers?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -333,14 +335,14 @@ class Openprovider {
if (isset($query['domain.extension'])) $ext = $query['domain.extension']; if (isset($query['domain.extension'])) $ext = $query['domain.extension'];
$cacheName = $name && $ext ? "domainprices-{$name}.{$ext}" : 'domainprices'; $cacheName = $name && $ext ? "domainprices-{$name}.{$ext}" : 'domainprices';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
$uri = "/domains/prices?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = "/domains/prices?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -403,8 +405,8 @@ class Openprovider {
public function listTlds(array $query = []): Result { public function listTlds(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listtlds'; $cacheName = 'listtlds';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ]; if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -413,7 +415,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -430,8 +432,8 @@ class Openprovider {
public function getTld(string $tld, array $query = []): Result { public function getTld(string $tld, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "gettld-{$tld}"; $cacheName = "gettld-{$tld}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -440,7 +442,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -460,8 +462,8 @@ class Openprovider {
public function listInvoices(array $query = []): Result { public function listInvoices(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listinvoices'; $cacheName = 'listinvoices';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -470,7 +472,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -489,8 +491,8 @@ class Openprovider {
public function listPayments(array $query = []): Result { public function listPayments(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listpayments'; $cacheName = 'listpayments';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -499,7 +501,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -518,8 +520,8 @@ class Openprovider {
public function listTransactions(array $query = []): Result { public function listTransactions(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listtransactions'; $cacheName = 'listtransactions';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -528,7 +530,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -570,8 +572,8 @@ class Openprovider {
public function listNameservers(array $query = []): Result { public function listNameservers(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listnameservers'; $cacheName = 'listnameservers';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ]; if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -580,7 +582,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -601,7 +603,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listnameservers'); $this->cache->murder('listnameservers');
return Result::Success('ネームサーバーの追加に成功。', $res->data); return Result::Success('ネームサーバーの追加に成功。', $res->data);
} }
@@ -619,8 +621,8 @@ class Openprovider {
public function getNameserver(string $domain, array $query = []): Result { public function getNameserver(string $domain, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "listnameserver-{$domain}"; $cacheName = "listnameserver-{$domain}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ]; if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -629,7 +631,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -651,8 +653,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listnameservers'); $this->cache->murder('listnameservers');
$this->murderCache("listnameserver-{$domain}"); $this->cache->murder("listnameserver-{$domain}");
if ($res->data['data']['success']) return Result::Success('ネームサーバーの更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('ネームサーバーの更新に成功。', $res->data);
} }
@@ -673,8 +675,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listnameservers'); $this->cache->murder('listnameservers');
$this->murderCache("listnameserver-{$domain}"); $this->cache->murder("listnameserver-{$domain}");
if ($res->data['data']['success']) return Result::Success('ネームサーバーの削除に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('ネームサーバーの削除に成功。', $res->data);
} }
@@ -693,8 +695,8 @@ class Openprovider {
public function listNsGroups(array $query = []): Result { public function listNsGroups(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listnsgroups'; $cacheName = 'listnsgroups';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ]; if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -703,7 +705,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -724,7 +726,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listnsgroups'); $this->cache->murder('listnsgroups');
return Result::Success('NSグループの追加に成功。', $res->data); return Result::Success('NSグループの追加に成功。', $res->data);
} }
@@ -742,8 +744,8 @@ class Openprovider {
public function getNsGroup(string $nsGroup, array $query = []): Result { public function getNsGroup(string $nsGroup, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "listnsgroup-{$nsGroup}"; $cacheName = "listnsgroup-{$nsGroup}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ]; if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -752,7 +754,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -774,8 +776,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listnsgroups'); $this->cache->murder('listnsgroups');
$this->murderCache("listnsgroup-{$nsGroup}"); $this->cache->murder("listnsgroup-{$nsGroup}");
if ($res->data['data']['success']) return Result::Success('NSグループの更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('NSグループの更新に成功。', $res->data);
} }
@@ -796,8 +798,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listnsgroups'); $this->cache->murder('listnsgroups');
$this->murderCache("listnsgroup-{$nsGroup}"); $this->cache->murder("listnsgroup-{$nsGroup}");
if ($res->data['data']['success']) return Result::Success('NSグループの削除に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('NSグループの削除に成功。', $res->data);
} }
@@ -816,8 +818,8 @@ class Openprovider {
public function listDnsTemplate(array $query = []): Result { public function listDnsTemplate(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listdnstemplates'; $cacheName = 'listdnstemplates';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/dns/templates?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/dns/templates?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -825,7 +827,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -846,7 +848,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdnstemplates'); $this->cache->murder('listdnstemplates');
return Result::Success('DNSテンプレートの追加に成功。', $res->data); return Result::Success('DNSテンプレートの追加に成功。', $res->data);
} }
@@ -863,14 +865,14 @@ class Openprovider {
public function getDnsTemplate(int $id): Result { public function getDnsTemplate(int $id): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getdnstemplate-{$id}"; $cacheName = "getdnstemplate-{$id}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
$uri = "/dns/templates/{$id}"; $uri = "/dns/templates/{$id}";
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -891,8 +893,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdnstemplates'); $this->cache->murder('listdnstemplates');
$this->murderCache("getdnstemplate-{$id}"); $this->cache->murder("getdnstemplate-{$id}");
if ($res->data['data']['success']) return Result::Success('DNSテンプレートの削除に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('DNSテンプレートの削除に成功。', $res->data);
} }
@@ -910,8 +912,8 @@ class Openprovider {
public function listDnsZones(array $query = []): Result { public function listDnsZones(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listdnszones'; $cacheName = 'listdnszones';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ]; if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -920,7 +922,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -941,7 +943,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdnszones'); $this->cache->murder('listdnszones');
return Result::Success('DNSゾーンの追加に成功。', $res->data); return Result::Success('DNSゾーンの追加に成功。', $res->data);
} }
@@ -958,8 +960,8 @@ class Openprovider {
public function getDnsZone(string $domain, array $query = []): Result { public function getDnsZone(string $domain, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getdnszone-{$domain}"; $cacheName = "getdnszone-{$domain}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ]; if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
@@ -968,7 +970,7 @@ class Openprovider {
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -990,8 +992,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdnszones'); $this->cache->murder('listdnszones');
$this->murderCache("getdnszone-{$domain}"); $this->cache->murder("getdnszone-{$domain}");
if ($res->data['data']['success']) return Result::Success('DNSゾーンの更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('DNSゾーンの更新に成功。', $res->data);
} }
@@ -1012,8 +1014,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdnszones'); $this->cache->murder('listdnszones');
$this->murderCache("getdnszone-{$domain}"); $this->cache->murder("getdnszone-{$domain}");
if ($res->data['data']['success']) return Result::Success('DNSゾーンの削除に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('DNSゾーンの削除に成功。', $res->data);
} }
@@ -1031,13 +1033,13 @@ class Openprovider {
public function listZoneRecords(string $domain): Result { public function listZoneRecords(string $domain): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getzonerecords-{$domain}"; $cacheName = "getzonerecords-{$domain}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache); if ($this->cache->validate($cache)) return Result::Success('', $cache);
$curl = $this->setupCurl("/dns/zones/{$domain}/records"); $curl = $this->setupCurl("/dns/zones/{$domain}/records");
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1060,8 +1062,8 @@ class Openprovider {
public function listEmails(array $query = []): Result { public function listEmails(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listemails'; $cacheName = 'listemails';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1069,7 +1071,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1090,7 +1092,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listemails'); $this->cache->murder('listemails');
return Result::Success('メールテンプレートの追加に成功。', $res->data); return Result::Success('メールテンプレートの追加に成功。', $res->data);
} }
@@ -1112,7 +1114,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listemails'); $this->cache->murder('listemails');
if ($res->data['data']['success']) return Result::Success('メールテンプレートの更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('メールテンプレートの更新に成功。', $res->data);
} }
@@ -1133,7 +1135,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listemails'); $this->cache->murder('listemails');
if ($res->data['data']['success']) return Result::Success('メールテンプレートの削除に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('メールテンプレートの削除に成功。', $res->data);
} }
@@ -1155,8 +1157,8 @@ class Openprovider {
public function listContacts(array $query = []): Result { public function listContacts(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listcontacts'; $cacheName = 'listcontacts';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/contacts?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/contacts?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1164,7 +1166,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1184,7 +1186,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res)) { if (isset($res)) {
$this->murderCache('listcontacts'); $this->cache->murder('listcontacts');
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1201,8 +1203,8 @@ class Openprovider {
public function getContact(int $id, bool $withAdditionalData = false): Result { public function getContact(int $id, bool $withAdditionalData = false): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getcontact-{$id}"; $cacheName = "getcontact-{$id}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $id, 'id')) return Result::Success('', $cache); if ($this->cache->validate($cache, $id, 'id')) return Result::Success('', $cache);
$query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ]; $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
$uri = "/contacts/{$id}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = "/contacts/{$id}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1211,7 +1213,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['id'] = $id; $res->data['id'] = $id;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1233,8 +1235,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache("getcontact-{$id}"); $this->cache->murder("getcontact-{$id}");
$this->murderCache('listcontacts'); $this->cache->murder('listcontacts');
if ($res->data['data']['success']) return Result::Success('連絡先の更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('連絡先の更新に成功。', $res->data);
} }
@@ -1254,8 +1256,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache("getcontact-{$id}"); $this->cache->murder("getcontact-{$id}");
$this->murderCache('listcontacts'); $this->cache->murder('listcontacts');
if ($res->data['data']['success']) return Result::Success('連絡先の削除に成功。'); if ($res->data['data']['success']) return Result::Success('連絡先の削除に成功。');
} }
@@ -1273,8 +1275,8 @@ class Openprovider {
public function listCustomers(array $query = []): Result { public function listCustomers(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listcustomers'; $cacheName = 'listcustomers';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/customers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/customers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1282,7 +1284,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1302,7 +1304,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res)) { if (isset($res)) {
$this->murderCache('listcustomers'); $this->cache->murder('listcustomers');
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1319,8 +1321,8 @@ class Openprovider {
public function getCustomer(string $handle, bool $withAdditionalData = false): Result { public function getCustomer(string $handle, bool $withAdditionalData = false): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getcustomer-{$handle}"; $cacheName = "getcustomer-{$handle}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $handle, 'handle')) return Result::Success('', $cache); if ($this->cache->validate($cache, $handle, 'handle')) return Result::Success('', $cache);
$query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ]; $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
$uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1329,7 +1331,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['handle'] = $handle; $res->data['handle'] = $handle;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1351,7 +1353,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listcustomers'); $this->cache->murder('listcustomers');
$this->cache->murder("getcustomer-{$handle}");
if ($res->data['data']['success']) return Result::Success('顧客様の更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('顧客様の更新に成功。', $res->data);
} }
@@ -1371,7 +1374,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listcustomers'); $this->cache->murder('listcustomers');
$this->cache->murder("getcustomer-{$handle}");
if ($res->data['data']['success']) return Result::Success('顧客様の削除に成功。'); if ($res->data['data']['success']) return Result::Success('顧客様の削除に成功。');
} }
@@ -1390,8 +1394,8 @@ class Openprovider {
public function listEmailVerifications(array $query = []): Result { public function listEmailVerifications(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listemailverifications'; $cacheName = 'listemailverifications';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/customers/verifications/emails/domains?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/customers/verifications/emails/domains?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1399,7 +1403,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1420,7 +1424,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'language' => $language, 'tag' => $tag]); $curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'language' => $language, 'tag' => $tag]);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listemailverifications'); $this->cache->murder('listemailverifications');
return Result::Success('メール認証の再起動に成功。', $res->data); return Result::Success('メール認証の再起動に成功。', $res->data);
} }
@@ -1444,7 +1448,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'handle' => $handle, 'language' => $language, 'tag' => $tag]); $curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'handle' => $handle, 'language' => $language, 'tag' => $tag]);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listemailverifications'); $this->cache->murder('listemailverifications');
return Result::Success('メール認証の起動に成功。', $res->data); return Result::Success('メール認証の起動に成功。', $res->data);
} }
@@ -1463,8 +1467,8 @@ class Openprovider {
public function getReseller(array $query = []): Result { public function getReseller(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'getreseller'; $cacheName = 'getreseller';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/resellers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/resellers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1472,7 +1476,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1494,7 +1498,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('getreseller'); $this->cache->murder('getreseller');
if ($res->data['data']['success']) return Result::Success('リセラーの更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('リセラーの更新に成功。', $res->data);
} }
@@ -1512,15 +1516,15 @@ class Openprovider {
public function listSettings(): Result { public function listSettings(): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listsettings'; $cacheName = 'listsettings';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
$uri = '/resellers/settings'; $uri = '/resellers/settings';
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1538,15 +1542,15 @@ class Openprovider {
public function listStatistics(array $query = []): Result { public function listStatistics(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'liststatistics'; $cacheName = 'liststatistics';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
$uri = '/resellers/statistics'; $uri = '/resellers/statistics';
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1565,8 +1569,8 @@ class Openprovider {
public function listTags(array $query = []): Result { public function listTags(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listtags'; $cacheName = 'listtags';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/tags?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/tags?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1574,7 +1578,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1595,7 +1599,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listtags'); $this->cache->murder('listtags');
return Result::Success('タグの追加に成功。', $res->data); return Result::Success('タグの追加に成功。', $res->data);
} }
@@ -1616,7 +1620,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE', $payload); $curl = $this->setupCurl($uri, 'DELETE', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listtags'); $this->cache->murder('listtags');
if ($res->data['data']['success']) return Result::Success('タグの削除に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('タグの削除に成功。', $res->data);
} }
@@ -1641,7 +1645,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', $payload); $curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res)) { if (isset($res)) {
$this->murderCache('listdomains'); $this->cache->murder('listdomains');
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1659,8 +1663,8 @@ class Openprovider {
public function getSeDomain(string $domain, array $query = []): Result { public function getSeDomain(string $domain, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getsedomain-{$domain}"; $cacheName = "getsedomain-{$domain}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $domain, 'domain')) return Result::Success('', $cache); if ($this->cache->validate($cache, $domain, 'domain')) return Result::Success('', $cache);
$uri = "/spam-expert/domains/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = "/spam-expert/domains/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
// kys($uri); // kys($uri);
@@ -1668,7 +1672,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['domain'] = $domain; $res->data['domain'] = $domain;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1690,8 +1694,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', $payload); $curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdomains'); $this->cache->murder('listdomains');
$this->murderCache("getsedomain-{$domain}"); $this->cache->murder("getsedomain-{$domain}");
if ($res->data['data']['success']) return Result::Success('SEDomainの更新に成功。', $res->data); if ($res->data['data']['success']) return Result::Success('SEDomainの更新に成功。', $res->data);
} }
@@ -1712,8 +1716,8 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'DELETE'); $curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->murderCache('listdomains'); $this->cache->murder('listdomains');
$this->murderCache("getsedomain-{$domain}"); $this->cache->murder("getsedomain-{$domain}");
if ($res->data['data']['success']) return Result::Success('SEDomainの削除に成功。'); if ($res->data['data']['success']) return Result::Success('SEDomainの削除に成功。');
} }
@@ -1734,8 +1738,8 @@ class Openprovider {
public function listApproverEmails(array $query = []): Result { public function listApproverEmails(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listapproveremails'; $cacheName = 'listapproveremails';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/ssl/approver-emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/ssl/approver-emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1743,7 +1747,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1811,7 +1815,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'PUT', ['id' => $id, 'approver_email' => $approverEmail]); $curl = $this->setupCurl($uri, 'PUT', ['id' => $id, 'approver_email' => $approverEmail]);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res)) { if (isset($res)) {
$this->murderCache('listapproveremails'); $this->cache->murder('listapproveremails');
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1832,7 +1836,7 @@ class Openprovider {
$curl = $this->setupCurl($uri, 'POST', ['id' => $id]); $curl = $this->setupCurl($uri, 'POST', ['id' => $id]);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res)) { if (isset($res)) {
$this->murderCache('listapproveremails'); $this->cache->murder('listapproveremails');
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1873,8 +1877,8 @@ class Openprovider {
public function listSslProducts(array $query = []): Result { public function listSslProducts(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listsslproducts'; $cacheName = 'listsslproducts';
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache); if ($this->cache->validate($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/ssl/products?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); $uri = '/ssl/products?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
@@ -1882,7 +1886,7 @@ class Openprovider {
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['query'] = $query; $res->data['query'] = $query;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1899,14 +1903,14 @@ class Openprovider {
public function getSslProduct(int $id): Result { public function getSslProduct(int $id): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getsslproduct-{$id}"; $cacheName = "getsslproduct-{$id}";
$cache = $this->getCache($cacheName); $cache = $this->cache->get($cacheName);
if ($this->isValidLifespan($cache, $id, 'id')) return Result::Success('', $cache); if ($this->cache->validate($cache, $id, 'id')) return Result::Success('', $cache);
// kys($uri); // kys($uri);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['id'] = $id; $res->data['id'] = $id;
$this->setCache($cacheName, $res->data); $this->cache->set($cacheName, $res->data);
return Result::Success('', $res->data); return Result::Success('', $res->data);
} }
@@ -1968,75 +1972,4 @@ class Openprovider {
return Result::Success('', json_decode($body, true)); return Result::Success('', json_decode($body, true));
} }
/**
* キャッシュの作成
*
* @param string $type キャッシュ類login、domainlist等
* @param array $data 保存するデータ
* @return Result
*/
private function setCache(string $type, array $data): Result {
if (!file_exists($this->dataDir)) {
if (!mkdir($this->dataDir, 0755))
return Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。');
}
$data['lifespan'] = time();
$json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if (file_put_contents("{$this->dataDir}{$type}.json", $json) === false) return Result::Error('エラー:ユーザーデータの保存に失敗。');
return Result::Success();
}
/**
* キャッシュから受け取り
*
* @param string $type キャッシュ類login、domainlist等
* @return array
*/
private function getCache(string $type): array {
if (!file_exists("{$this->dataDir}{$type}.json")) return [];
$content = file_get_contents("{$this->dataDir}{$type}.json");
if ($content === false) return [];
$data = json_decode($content, true);
if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) return [];
if ($type === 'login') {
$this->token = $data['data']['token'];
$this->lastAuth = $data['last_auth'];
}
return $data;
}
/**
* キャッシュを破壊する
*
* @param string $name キャッシュのファイル名
* @return Result
*/
private function murderCache(string $name): Result {
if (!file_exists("{$this->dataDir}{$name}.json")) return Result::Error('キャッシュファイルが存在しない。');
if (!unlink("{$this->dataDir}{$name}.json")) return Result::Error('キャッシュファイルの削除に失敗。');
return Result::Success();
}
/**
* キャッシュ有効期限の確認
*
* @param array $cache
* @param mixed $data デフォルトnull
* @param string $dataPoint デフォルトquery
* @return bool
*/
private function isValidLifespan(array $cache, mixed $data = null, string $dataPoint = 'query'): bool {
if (NULL === $data) return (!empty($cache) && (isset($cache['lifespan']) && time() < ($cache['lifespan'] + $this->dataDuration)));
else return (!empty($cache)
&& (isset($cache[$dataPoint])
&& $cache[$dataPoint] === $data)
&& (isset($cache['lifespan']) && time() < ($cache['lifespan'] + $this->dataDuration)));
}
} }

View File

@@ -108,5 +108,4 @@
<button>送信</button> <button>送信</button>
</form> </form>
</p> </p>
{@ kys($data) @}
{@ include(common/footer) @} {@ include(common/footer) @}

View File

@@ -1,5 +1,5 @@
{@ include(common/header) @} {@ include(common/header) @}
<a href="/openprovider/createcustomer">顧客様の追加</a><br /> <a href="/openprovider/createcustomer" class="op-button-create">顧客様の追加</a><br />
検索<br /> 検索<br />
{@ if (isset($data['data']['results'])) @} {@ if (isset($data['data']['results'])) @}
<table> <table>