cache

package
v1.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParallelGet

func ParallelGet(iterations int, urls ...string) error

Parallel get will perform a get request on the given urls. Does not check response code or body, simply checks if the request received a response

func ParallelGetWithBodyCheck

func ParallelGetWithBodyCheck(iterations int, toTest ...GetTester) error

ParallelGetWithBodyCheck is the same as ParallelGet, but will check body for expected response, and failure response if given.

func ResolveAssetCid

func ResolveAssetCid(serviceable iface.Serviceable) (string, error)

TODO: This should return a cid.Cid

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

The Cache struct wraps cache methods for use by node-services.

func New

func New() *Cache

New creates new cache object to be used by Node sub-services for caching serviceables.

The serviceables are stored in a map of serviceables map, where the map key is the matcher cache prefix value. The serviceable itself is stored by the id of the serviceable.

func (*Cache) Add

func (c *Cache) Add(serviceable iface.Serviceable) (iface.Serviceable, error)

Add method adds the serviceable to the given Cache object.

func (*Cache) Close

func (c *Cache) Close()

Close safely clears the cache and releases resources.

This method locks the cache, sets the cacheMap to nil, and then unlocks the cache to ensure that other goroutines can safely access the cache once it has been cleared.

func (*Cache) Get

func (c *Cache) Get(matcher iface.MatchDefinition, ops iface.GetOptions) ([]iface.Serviceable, error)

Get method gets the list of serviceables from the cache map, where the serviceables that are returned are those with a high match for given match definition.

func (*Cache) Remove

func (c *Cache) Remove(serviceable iface.Serviceable)

Remove removes a single serviceable from the cache.

type GetTester

type GetTester struct {
	Url             string
	PassingResponse *ResponseCheck
	FailingResponse *ResponseCheck
}

type ResponseCheck

type ResponseCheck struct {
	Body []byte
	Code int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL