UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Qw18i9xuJpLI46RAEhP0lQT80VSUjxyy0USaTeRFVE4='
WHERE
key_id = 'd698e447d782fc99a176e1ce5df110e53f20d5b429c253867b68873fe4553b4c'
AND (
token = 'Qw18i9xuJpLI46RAEhP0lQT80VSUjxyy0USaTeRFVE4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)