cache

package
v0.0.0-...-89c1cf6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountWebRequest

func CountWebRequest() (int64, error)

CountWebRequest returns the number of failed web request pending for analysis.

func DequeueRequests

func DequeueRequests() ([]string, error)

DequeueRequests returns all pending requests ready to be inserted into the database.

func Get

func Get(key string) (string, error)

Get returns a value for a key.

func GetRateLimitExpiration

func GetRateLimitExpiration(key string) (time.Duration, error)

GetRateLimitExpiration returns the duration before a key expire for rate limit.

func GetThrottleExpiration

func GetThrottleExpiration(key string) (time.Duration, error)

GetThrottleExpiration returns the duration before a key expire for throttling.

func GetWebRequest

func GetWebRequest(first bool) (reqID string, b []byte, err error)

GetWebRequest returns the next web request logged from list.

func LogRequest

func LogRequest(v interface{}) error

LogRequest adds a new item to the list of pending request to be logged.

func LogWebRequest

func LogWebRequest(reqID string, b []byte) error

LogWebRequest saves a web request for further analysis.

func New

func New(queueProcessor, isDev bool, ex map[queue.TaskID]queue.TaskExecutor)

New initializes the queue service via the queue.New function.

The queueProcessor flag indicates if this instance will act as the Pub/Sub subscriber. There must be only one subscriber.

The ex parameter map[queue.TaskID]queue.Executor allow you to supply custom executors for your own custom task. A TaskExecutor must satisfy this interface.

type TaskExecutor interface {
	Run(t QueueTask) error
}

func RateLimit

func RateLimit(key string, expire time.Duration) (int64, error)

RateLimit increments the requests count for a specific key and set expiration if it's a new period.

func Set

func Set(key, value string) (string, error)

Set sets a value for a key.

func Throttle

func Throttle(key string, expire time.Duration) (int64, error)

Throttle increments the requests count for a specific key and set expiration if it's a new period.

Types

type Auth

type Auth struct{}

Auth is used to get/set authentication related keys

func (*Auth) Exists

func (x *Auth) Exists(key string, v interface{}) error

Exists returns the authentication from cache.

func (*Auth) Set

func (x *Auth) Set(key string, v interface{}, expiration time.Duration) error

Set cache this key (authentication) for 30 minutes.

Jump to

Keyboard shortcuts

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