cache

package
v2.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

package cache stores data in memeory to reduce database calls and increase speed of data fetching

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRunTimer

func NewRunTimer(name string, logger *logger.Logger) *runTimer

Types

type AccountsForUser

type AccountsForUser map[types.AccountID]*types.Account

type Cache

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

The Cache struct provides an in-memory cache for data used across the Portal API backend architecture. It allows for efficient querying, insertion, and updating of these entities through appropriate cache methods.

It also uses a Listener that listens for Postgres Notifications in order to update multiple instances of the Cache in response to inserts, updates and deletes on a single Postgres database.

func NewCache

func NewCache(ctx context.Context, config Config) (*Cache, error)

NewCache returns cache instance from reader interface and starts the cache refresh handler and listener in separate goroutines

func (*Cache) GetAccount added in v2.5.0

func (c *Cache) GetAccount(accountID types.AccountID) types.Account

GetAccount returns one Accounts from cache

func (*Cache) GetAccounts

func (c *Cache) GetAccounts(options Options) []types.Account

GetAccounts returns all Accounts in cache May select whether to include deleted Accounts. Default: false

func (*Cache) GetBlockedContracts

func (c *Cache) GetBlockedContracts() types.GlobalBlockedContracts

GetBlockedContracts returns all global blocked contracts

func (*Cache) GetChain

func (c *Cache) GetChain(chainID types.RelayChainID, options Options) types.Chain

GetChain returns Chain from cache by chainID

func (*Cache) GetChains

func (c *Cache) GetChains(options Options) []types.Chain

GetChains returns all Chains from cache

func (*Cache) GetGatewayConfig added in v2.14.0

func (c *Cache) GetGatewayConfig(env types.Environment) types.GatewayConfig

GetGatewayConfig returns the GatewayConfig from the cache

func (*Cache) GetGigastakeAppByID

func (c *Cache) GetGigastakeAppByID(gigastakeAppID types.GigastakeAppID) types.GigastakeApp

GetGigastakeAppByID returns GigastakeApp from cache by aatID

func (*Cache) GetGigastakeApps

func (c *Cache) GetGigastakeApps(options Options) []types.GigastakeApp

GetGigastakeApps returns all GigastakeApps in cache

func (*Cache) GetOpenAPISpecs added in v2.11.0

func (c *Cache) GetOpenAPISpecs() map[types.RelayChainID]json.RawMessage

GetOpenAPISpecs returns the OpenAPISpecs from the cache

func (*Cache) GetPlan

func (c *Cache) GetPlan(planType types.PayPlanType) types.Plan

GetPlan returns Plan from cache by planType

func (*Cache) GetPlans

func (c *Cache) GetPlans() []types.Plan

GetPlans returns all PayPlans in cache

func (*Cache) GetPortalApp

func (c *Cache) GetPortalApp(portalAppID types.PortalAppID) types.PortalApp

GetPortalApp returns PortalApp from cache by portalAppID

func (*Cache) GetPortalApps

func (c *Cache) GetPortalApps(options Options) []types.PortalApp

GetPortalApps returns all PortalApps in cache

func (*Cache) GetPortalAppsByUserID

func (c *Cache) GetPortalAppsByUserID(userID types.UserID) []types.PortalApp

func (*Cache) GetPortalAppsForMiddleware

func (c *Cache) GetPortalAppsForMiddleware() []types.PortalAppLite

GetPortalAppsForMiddleware returns all PortalAppLites in cache

func (*Cache) GetUserAccount

func (c *Cache) GetUserAccount(accountID types.AccountID, userID types.UserID, options Options) types.Account

GetUserAccount returns one Account by accountID with portal apps filtered by user ID

func (*Cache) GetUserAccounts

func (c *Cache) GetUserAccounts(userID types.UserID, options Options) []types.Account

func (*Cache) GetUserByID

func (c *Cache) GetUserByID(userID types.UserID) types.User

GetUserByID returns the Portal User for a given portal UserID

func (*Cache) GetUserByProviderID

func (c *Cache) GetUserByProviderID(providerUserID types.ProviderUserID) types.User

GetUserByProviderID returns the Portal User for a given provider UserID

func (*Cache) GetValidatorConfig added in v2.8.0

func (c *Cache) GetValidatorConfig() types.ValidatorPluginConfig

GetValidatorConfig returns the ValidatorPluginConfig from the cache

func (*Cache) ResetCache

func (c *Cache) ResetCache(ctx context.Context) error

ResetCache manually resets the cache; called in the router when the `/reset_cache` endpoint is hit.

type Config

type Config struct {
	Reader              driver.Reader
	Logger              *logger.Logger
	CacheRefreshMinutes time.Duration
}

type Options

type Options struct {
	IncludeDeleted            bool
	IncludeInactiveChains     bool
	ExcludeChainGigastakeApps bool
	FullDetails               bool
	FilterAccounts            []types.RoleName
	Accepted                  *bool
}

type ReaderMock

type ReaderMock struct {
	driver.MockDriver
	// contains filtered or unexported fields
}

func NewReaderMock

func NewReaderMock(t *testing.T) (*ReaderMock, context.CancelFunc)

func (*ReaderMock) NotificationChannel

func (r *ReaderMock) NotificationChannel() <-chan *types.Notification

type UsersForAccount added in v2.5.0

type UsersForAccount map[types.UserID]*types.User

Jump to

Keyboard shortcuts

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