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