UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'K+XVqvSroJkDGIKkH3fNSPYisW3QmhCpHPKAKT417DA='
WHERE
key_id = 'a1e3bf58ea92c847c6810fe38b4906a6447e9c9292cf5d535e9563a9f1a3c697'
AND (
token = 'K+XVqvSroJkDGIKkH3fNSPYisW3QmhCpHPKAKT417DA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)