repository

package
v0.0.0-...-bc7015d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENOTFOUND  = "not found"
	EINTERNAL  = "server error"
	EMALFORMED = "schema invalid"
)

Variables

This section is empty.

Functions

func NewHealthResponse

func NewHealthResponse(code int, message string) *healthResponse

func NewitemsResponse

func NewitemsResponse(i *models.Items) *itemsResponse

NewitemsResponse creates itemsResponse object

Types

type CacheStore

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

func NewCacheStore

func NewCacheStore(c *ttlcache.Cache) *CacheStore

NewCacheStore constructor: returns instance of CacheStore

func (*CacheStore) Count

func (c *CacheStore) Count() int

Count returns the number of items in the cache

func (*CacheStore) Get

func (c *CacheStore) Get(key string) (interface{}, bool)

Get retrieves key from cache store

func (*CacheStore) Set

func (c *CacheStore) Set(key string, data interface{}) error

Set adds key and data into cache store

func (*CacheStore) SetCacheSizeLimit

func (c *CacheStore) SetCacheSizeLimit(limit int)

SetCacheSizeLimit sets the max number of items stored in cache

func (*CacheStore) SetTTL

func (c *CacheStore) SetTTL(ttl time.Duration)

SetTTL sets global TTL expiration of keys inside cache store

type Error

type Error struct {
	Status  int    `json:"Status"`
	Cause   string `json:"-"`
	Message string `json:"Message"`
}

func NewError

func NewError(err error, code int, errMessage string) Error

func NotFound

func NotFound() Error

func (*Error) Error

func (e *Error) Error() string

type ItemStore

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

func NewItemStore

func NewItemStore(db *sqlx.DB) *ItemStore

func (*ItemStore) Create

func (t *ItemStore) Create(i *models.Items) (*models.Items, error)

func (*ItemStore) GetAll

func (t *ItemStore) GetAll() ([]models.Items, error)

func (*ItemStore) GetById

func (t *ItemStore) GetById(id int) (*models.Items, error)

type ItemsI

type ItemsI interface {
	GetAll() ([]models.Items, error)
	GetById(id int) (*models.Items, error)
	Create(i *models.Items) (*models.Items, error)
}

type ServerCache

type ServerCache interface {
	Get(key string) (interface{}, bool)
	Set(key string, data interface{}) error
	SetTTL(ttl time.Duration)
	SetCacheSizeLimit(limit int)
	Count() int
}

Jump to

Keyboard shortcuts

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