UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'B9RtzPoO9t7PGXTkz9zAD9Ut3MXKA2o349zemPSVhAo='
WHERE
key_id = '9170aff0fe9a9264f876dc345407192ee89a207ff8fcbaf3e9eff1acc8b0df07'
AND (
token = 'B9RtzPoO9t7PGXTkz9zAD9Ut3MXKA2o349zemPSVhAo='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)