UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Y3infNNUaAfxawcFJwfoHNtWIxQxAxu1ssC5N8k/Rc8='
WHERE
key_id = 'e3fc5037524005bf886aacb4fd8251adc59891126a9faec6bb8dc5927e0082fe'
AND (
token = 'Y3infNNUaAfxawcFJwfoHNtWIxQxAxu1ssC5N8k/Rc8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)