UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gyU4mvOrE3CnOa9AYnw6Bch28OxSrMnGIGnE2ikHJs8='
WHERE
key_id = '8ab09f9d6c1dd9c08324febb9645cb5c022cb21e01c8955170ddc86d99317d9a'
AND (
token = 'gyU4mvOrE3CnOa9AYnw6Bch28OxSrMnGIGnE2ikHJs8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)