UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ZZAe2pKekrni1ez2jFKI+9SO5kIqBhxi+6Mb7ABk9cs='
WHERE
key_id = 'd477107a3ff8dbd16e927e330fc7d73b6890661348caed41dc30af60b002d04c'
AND (
token = 'ZZAe2pKekrni1ez2jFKI+9SO5kIqBhxi+6Mb7ABk9cs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)