Documentation
¶
Overview ¶
Package cloudflare provides a Cloudflare API v4 client for Commerce.
Used for:
- Purging cached URLs or Cache-Tag groups after writes
- Wiring CF cache invalidation into model AfterSave/AfterDelete hooks
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConfigured ¶ added in v1.36.4
func IsConfigured() bool
IsConfigured returns true when CF credentials and zone are set.
func PurgeAfterWrite ¶ added in v1.36.4
func PurgeAfterWrite(tags ...string)
PurgeAfterWrite is a helper that fires a background CF cache-tag purge after a model write. Call from AfterSave/AfterDelete model hooks.
cf := cloudflare.NewBackground()
cf.PurgeAfterWrite("plans", "org:hanzo")
Types ¶
type Client ¶
type Client struct {
Email string
Key string
Zone string
Endpoint string
// contains filtered or unexported fields
}
Client is a Cloudflare API v4 client.
func NewBackground ¶ added in v1.36.4
func NewBackground() *Client
NewBackground creates a Client suitable for background goroutines (no gin context).
func (*Client) Purge ¶
Purge removes specific URLs from CF cache. zone defaults to the configured zone if empty.
func (*Client) PurgeEverything ¶ added in v1.36.4
func (c *Client) PurgeEverything()
PurgeEverything purges the entire CF cache for the zone. Use sparingly — only for full deploys or catastrophic staleness.
func (*Client) PurgeTags ¶ added in v1.36.4
PurgeTags removes all CF cache entries that match the given Cache-Tag values. This is the most targeted invalidation strategy — tag writes at insertion time with SetCFCacheTags() and purge by tag on mutations.
Tags are auto-split on commas so a single comma-joined string is also accepted.