mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 06:35:15 +00:00
oembed cache: don't store the url (which may need to be truncated), store a hash instead. This will allow us to convert the table to utf8mb4 without running into mysql key length restrictions as well as dealing with the potential ambiguity of truncated urls.
This commit is contained in:
parent
a037758245
commit
53bd0146bb
1 changed files with 6 additions and 6 deletions
|
@ -9,10 +9,10 @@ namespace Zotlabs\Lib;
|
|||
class Cache {
|
||||
public static function get($key) {
|
||||
|
||||
$key = substr($key,0,254);
|
||||
$hash = hash('whirlpool',$key);
|
||||
|
||||
$r = q("SELECT v FROM cache WHERE k = '%s' limit 1",
|
||||
dbesc($key)
|
||||
dbesc($hash)
|
||||
);
|
||||
|
||||
if ($r)
|
||||
|
@ -22,20 +22,20 @@ class Cache {
|
|||
|
||||
public static function set($key,$value) {
|
||||
|
||||
$key = substr($key,0,254);
|
||||
$hash = hash('whirlpool',$key);
|
||||
|
||||
$r = q("SELECT * FROM cache WHERE k = '%s' limit 1",
|
||||
dbesc($key)
|
||||
dbesc($hash)
|
||||
);
|
||||
if($r) {
|
||||
q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'",
|
||||
dbesc($value),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($key));
|
||||
dbesc($hash));
|
||||
}
|
||||
else {
|
||||
q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')",
|
||||
dbesc($key),
|
||||
dbesc($hash),
|
||||
dbesc($value),
|
||||
dbesc(datetime_convert()));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue