UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '58JdYeFYkBEImAHDHGKldwhD43TSFoVGY0Vtc3QCajQ='
WHERE
key_id = 'c285ac04996d725007e69659b4cdf317b7b271d52b681f9c65f957a785c4ad50'
AND (
token = '58JdYeFYkBEImAHDHGKldwhD43TSFoVGY0Vtc3QCajQ='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)