UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Ub+ERf6SYImqSRgvRZtgwl44ypQXN7CTDUjh8vvN+1s='
WHERE
key_id = 'c747984fc38fd9e1b601e32f3e4d10867ee8d37509aa64376275021ac978347b'
AND (
token = 'Ub+ERf6SYImqSRgvRZtgwl44ypQXN7CTDUjh8vvN+1s='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)