mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
fix cache selection method
This commit is contained in:
parent
03ac7647b7
commit
5b020095a3
2 changed files with 14 additions and 30 deletions
|
|
@ -239,17 +239,9 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
|
||||||
string $request
|
string $request
|
||||||
): ?object
|
): ?object
|
||||||
{
|
{
|
||||||
if ($cache = $this->_database->findCache($request))
|
return $this->_database->getCache(
|
||||||
{
|
$request
|
||||||
if (empty($cache[0]))
|
);
|
||||||
{
|
|
||||||
throw new \Exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $cache[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cache(
|
public function cache(
|
||||||
|
|
|
||||||
|
|
@ -132,35 +132,27 @@ class Database
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findCache(
|
public function getCache(
|
||||||
string $request = '',
|
string $request = ''
|
||||||
int $start = 0,
|
): ?object
|
||||||
int $limit = 1000
|
|
||||||
): array
|
|
||||||
{
|
{
|
||||||
$query = $this->_connection->prepare(
|
$query = $this->_connection->prepare(
|
||||||
sprintf(
|
'SELECT * FROM `cache` WHERE `request` LIKE :request LIMIT 1'
|
||||||
'SELECT * FROM `cache`
|
|
||||||
WHERE `request` LIKE :request
|
|
||||||
ORDER BY `id` DESC
|
|
||||||
LIMIT %d,%d',
|
|
||||||
$start,
|
|
||||||
$limit
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$query->execute(
|
$query->execute(
|
||||||
[
|
[
|
||||||
':request' => sprintf(
|
':request' => $request
|
||||||
'%%%s%%',
|
|
||||||
$request
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return $query->fetchAll();
|
if ($cache = $query->fetch())
|
||||||
}
|
{
|
||||||
|
return $cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function deleteCache(
|
public function deleteCache(
|
||||||
int $id
|
int $id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue