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