mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45: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
|
||||
): ?object
|
||||
{
|
||||
if ($cache = $this->_database->findCache($request))
|
||||
{
|
||||
if (empty($cache[0]))
|
||||
{
|
||||
throw new \Exception;
|
||||
}
|
||||
|
||||
return $cache[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->_database->getCache(
|
||||
$request
|
||||
);
|
||||
}
|
||||
|
||||
public function cache(
|
||||
|
|
|
|||
|
|
@ -132,35 +132,27 @@ class Database
|
|||
);
|
||||
}
|
||||
|
||||
public function findCache(
|
||||
string $request = '',
|
||||
int $start = 0,
|
||||
int $limit = 1000
|
||||
): array
|
||||
public function getCache(
|
||||
string $request = ''
|
||||
): ?object
|
||||
{
|
||||
$query = $this->_connection->prepare(
|
||||
sprintf(
|
||||
'SELECT * FROM `cache`
|
||||
WHERE `request` LIKE :request
|
||||
ORDER BY `id` DESC
|
||||
LIMIT %d,%d',
|
||||
$start,
|
||||
$limit
|
||||
)
|
||||
'SELECT * FROM `cache` WHERE `request` LIKE :request LIMIT 1'
|
||||
);
|
||||
|
||||
$query->execute(
|
||||
[
|
||||
':request' => sprintf(
|
||||
'%%%s%%',
|
||||
$request
|
||||
)
|
||||
':request' => $request
|
||||
]
|
||||
);
|
||||
|
||||
return $query->fetchAll();
|
||||
}
|
||||
if ($cache = $query->fetch())
|
||||
{
|
||||
return $cache;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function deleteCache(
|
||||
int $id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue