Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheController ¶
type CacheController interface {
// DetermineInvalidationTime returns the timestamp of the last write for the
// specified store if it was in cache, else it returns the Zero time and
// triggers InvalidateIfNeeded(). The last write time can be used to determine
// whether a cached entry is still valid - if it was cached before the last
// write to the store, it can't be trusted anymore.
DetermineInvalidationTime(context.Context, string) time.Time
// InvalidateIfNeeded checks to see if an invalidation is currently in progress for a store,
// and if not it will spawn a goroutine to invalidate cached records conditionally
// based on timestamp. It may invalidate all cache records, some, or none.
InvalidateIfNeeded(context.Context, string)
}
func NewCacheController ¶
func NewCacheController( ds storage.OpenFGADatastore, cache storage.InMemoryCache[any], ttl time.Duration, queryCacheTTL time.Duration, iteratorCacheTTL time.Duration, opts ...InMemoryCacheControllerOpt, ) CacheController
func NewNoopCacheController ¶
func NewNoopCacheController() CacheController
type InMemoryCacheController ¶
type InMemoryCacheController struct {
// contains filtered or unexported fields
}
InMemoryCacheController will invalidate cache iterator (InMemoryCache) and sub problem cache (CachedCheckResolver) entries that are more recent than the last write for the specified store. Note that the invalidation is done asynchronously, and only after a Check request is received. It will be eventually consistent.
func (*InMemoryCacheController) DetermineInvalidationTime ¶ added in v1.8.5
func (c *InMemoryCacheController) DetermineInvalidationTime( ctx context.Context, storeID string, ) time.Time
DetermineInvalidationTime returns the timestamp of the last write for the specified store if it was in cache, else it returns the Zero time and triggers InvalidateIfNeeded(). The last write time can be used to determine whether a cached entry is still valid - if it was cached before the last write to the store, it can't be trusted anymore.
func (*InMemoryCacheController) InvalidateIfNeeded ¶ added in v1.8.10
func (c *InMemoryCacheController) InvalidateIfNeeded(ctx context.Context, storeID string)
InvalidateIfNeeded checks to see if an invalidation is currently in progress for a store, and if not it will spawn a goroutine to invalidate cached records conditionally based on timestamp. It may invalidate all cache records, some, or none.
type InMemoryCacheControllerOpt ¶ added in v1.8.5
type InMemoryCacheControllerOpt func(*InMemoryCacheController)
InMemoryCacheControllerOpt defines an option that can be used to change the behavior of InMemoryCacheController instance.
func WithLogger ¶ added in v1.8.5
func WithLogger(logger logger.Logger) InMemoryCacheControllerOpt
WithLogger sets the logger for InMemoryCacheController.
type NoopCacheController ¶
type NoopCacheController struct{}
func (*NoopCacheController) DetermineInvalidationTime ¶ added in v1.8.5
func (*NoopCacheController) InvalidateIfNeeded ¶ added in v1.8.10
func (c *NoopCacheController) InvalidateIfNeeded(_ context.Context, _ string)