cache

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 6 Imported by: 6 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

caching

caching library used by connectors

How it works :

connector should check if IsKeyCreated if key is not already created, connector should CreateCache.

Caching has 2 functionalities:

1- IsKeyCreated it takes objectID which check if the provided key is already cached, key is a full path for connectors it is cache/{connectorName}/{objectID}

2- CreateCache which store a cache record, it takes []map[string]interface each map contain 2 keys id and data.id is the objectID. data is the bytes of the actual object.

3- GetLastSync which get connector last sync date

4- SetLastSync which update connector last sync date

Documentation

Index

Constants

View Source
const (
	Path         = "cache/%s/%s/%s"
	LastSyncFile = "0000-last-sync"
	Bucket       = "insights-v2-cache-%s"
	Region       = "us-east-2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager(connector string, environment string) *Manager

func (*Manager) Create

func (m *Manager) Create(endpoint string, data []map[string]interface{}) error

Create new cache record

func (*Manager) GetLastSync

func (m *Manager) GetLastSync(endpoint string) (time.Time, error)

GetLastSync get connector sync date, if it is not exist return epoch date

func (*Manager) IsKeyCreated

func (m *Manager) IsKeyCreated(endpoint string, id string) (bool, error)

IsKeyCreated check if the key already exists

func (*Manager) SetLastSync

func (m *Manager) SetLastSync(endpoint string, lastSync time.Time) error

SetLastSync update connector last sync date

type S3Manager

type S3Manager interface {
	Save(payload []byte) error
	SaveWithKey(payload []byte, key string) error
	GetKeys() ([]string, error)
	Get(key string) ([]byte, error)
	Delete(key string) error
}

S3Manager used in connecting to s3

Jump to

Keyboard shortcuts

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