Categorygithub.com/covrom/ldcache
modulepackage
1.1.1
Repository: https://github.com/covrom/ldcache.git
Documentation: pkg.go.dev

# README

ldcache

Loading cache with Go generics 1.18+

Example of usage:

var idCache *ldcache.Cache[uuid.UUID, *User]

idCache = ldcache.NewCache(
    tcache.CacheParams[uuid.UUID, *User]{
        Loader: func(ctx context.Context, key uuid.UUID) (*User, error) {
                return UserDataFromStoreByID(key)
            },
        Size:    cacheCount,
        Expires: time.Hour * 12,
    },
)

vuser, err := idCache.Get(ctx, id)

# Functions

No description provided by the author

# Constants

No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author

# Interfaces

LoadingCache is a cache with values are loaded automatically and stored in the cache until either evicted or manually invalidated.
SomeCache is a key-value cache which entries are added and stayed in the cache until either are evicted or manually invalidated.

# Type aliases

No description provided by the author
Func is a generic callback for entry events in the cache.
Key is any value which is comparable.
LoaderFunc retrieves the value corresponding to given Key.
Value is any value.