uniugm/admin/lib/cdn/tencent.go
2025-07-09 10:55:26 +08:00

31 lines
628 B
Go

package cdn
import (
"context"
"fmt"
v20180606 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdn/v20180606"
"time"
)
func PurgeTxCdnPath(secretId, secretKey, region, path string) error {
c, err := v20180606.NewClientWithSecretId(secretId, secretKey, region)
if err != nil {
return fmt.Errorf("NewClientWithSecretId error:%v", err)
}
ctx, cf := context.WithTimeout(context.Background(), time.Second*10)
defer cf()
flush := "flush"
req := v20180606.NewPurgePathCacheRequest()
req.Paths = []*string{
&path,
}
req.FlushType = &flush
_, err = c.PurgePathCacheWithContext(ctx, req)
return err
}