UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'BWcBKLMuP3fQyNpZ/1Ap5UncBbdc0psDrZ2vuOV7rh8='
WHERE
key_id = 'dec4af6dad257b62142a9371c410c912364379d16f1f34d650318fc0b7e1a2c2'
AND (
token = 'BWcBKLMuP3fQyNpZ/1Ap5UncBbdc0psDrZ2vuOV7rh8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)