cache

package
v1.5.32 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 6 Imported by: 4

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 LastSyncData added in v1.5.26

type LastSyncData struct {
	LastSync time.Time `json:"last_sync"`
}

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) GetFileByKey

func (m *Manager) GetFileByKey(endpoint string, id string) ([]byte, error)

GetFileByKey get file by key

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) GetLastSyncFile added in v1.5.26

func (m *Manager) GetLastSyncFile(endpoint string) ([]byte, error)

GetLastSyncFile get connector last sync file, if it is not exist return empty file with last sync 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

func (*Manager) SetLastSyncFile added in v1.5.26

func (m *Manager) SetLastSyncFile(endpoint string, data []byte) error

SetLastSyncFile update connector last sync file date

func (*Manager) UpdateFileByKey

func (m *Manager) UpdateFileByKey(endpoint string, id string, data []byte) error

UpdateFileByKey get file by key

func (*Manager) UpdateMultiPartFileByKey added in v1.5.30

func (m *Manager) UpdateMultiPartFileByKey(endpoint string, id string) error

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
	UploadMultipart(fileName string, path 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