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