UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'nAm2CsONPfOaYRXUhgmo0eF0F4torlUQmqU6EsKaJOk='
WHERE
key_id = '402cd1b05421ad47caee34f4297c9259b448e60257b1730d74f3f4f16253547a'
AND (
token = 'nAm2CsONPfOaYRXUhgmo0eF0F4torlUQmqU6EsKaJOk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)