...

Package cache

import "github.com/LINBIT/golinstor/cache"
Overview
Index

Overview ▾

Package cache

Implement client side caching for client.Client. This is useful for burst-happy applications that will try to query a lot of the same information in small chunks.

For example, an application could try to check the state of nodes, but do so using one request per node. This is obviously not ideal in larger cluster, where it would be more efficient to request the state of all nodes at once. Depending on the application, this may not be possible, however.

This package contains ready-to-use client side caches with configurable duration and automatic invalidation under the assumption that modifications are made from the same client.

func WithCaches

func WithCaches(caches ...Cache) client.Option

WithCaches sets up the given caches on the client.Client.

type Cache

type Cache interface {
    // contains filtered or unexported methods
}

type NodeCache

NodeCache caches respones from a client.NodeProvider.

type NodeCache struct {
    // Timeout for the cached responses.
    Timeout time.Duration
    // contains filtered or unexported fields
}

type ResourceCache

ResourceCache caches responses from a client.ResourceProvider.

type ResourceCache struct {
    // Timeout for the cached responses.
    Timeout time.Duration
    // contains filtered or unexported fields
}