data

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemory

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

InMemory holds the options and for with in memory key-value data store

func NewInMemory

func NewInMemory(options *Options) *InMemory

NewInMemory returns new InMemory client

func (*InMemory) Add added in v0.2.0

func (i *InMemory) Add(key string, resource string, now time.Time) (int, error)

Add new hit for particular 'resource' in particular time bucket 'key'

func (*InMemory) Connect

func (i *InMemory) Connect() error

Connect to InMemory database

func (*InMemory) Create added in v0.2.0

func (i *InMemory) Create(key string, resource string) error

Create bucket in InMemory for specitic time slot and resource name

func (*InMemory) Delete

func (i *InMemory) Delete(key string) error

Delete a specific 'key' time bucket

func (*InMemory) Get

func (i *InMemory) Get(key string, resource string) (int, error)

Get hits count from InMemory based on bucket key and resource name

func (*InMemory) Has

func (i *InMemory) Has(key string) bool

Has checks if the time slot bucket 'key' exists

func (*InMemory) Options

func (i *InMemory) Options() *Options

Options returns the current options passed to InMemory

type Options

type Options struct {
	RedisURL      string
	RedisPort     int
	RedisPassword string
}

Options respresents the available options to be passed to data store implementations. These can be set with flags through the CLI or environment variable to Docker container.

type Redis

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

Redis holds the client and options for connecting and working against Redis

func NewRedis

func NewRedis(options *Options) *Redis

NewRedis returns new Redis client with provided URL and port and password through CLI options

func (*Redis) Add added in v0.2.0

func (r *Redis) Add(key string, resource string, now time.Time) (int, error)

Add new hit for particular 'resource' in particular time bucket 'key'

func (*Redis) Connect

func (r *Redis) Connect() error

Connect connects to Redis database

func (*Redis) Create added in v0.2.0

func (r *Redis) Create(key string, resource string) error

Create bucket in Redis for specitic time slot and resource name

func (Redis) Delete

func (r Redis) Delete(key string) error

Delete a specific 'key' time bucket

func (*Redis) Get

func (r *Redis) Get(key string, resource string) (int, error)

Get hits count from Redis based on bucket key and resource name

func (*Redis) Has

func (r *Redis) Has(key string) bool

Has checks if the time slot bucket 'key' exists

func (*Redis) Options

func (r *Redis) Options() *Options

Options returns the current options passed to Redis

type Store

type Store interface {
	// Options returns the current options passed to Store
	Options() *Options

	// Connect connects to Store database
	Connect() error

	// Has checks if the time slot bucket 'key' exists
	Has(key string) bool

	// Get hits count based on bucket key and resource name
	Get(key string, resource string) (int, error)

	// Create bucket for specitic time slot and resource name
	Create(key string, resource string) error

	// Add new hit for particular 'resource' in particular time bucket 'key'
	Add(key string, resource string, now time.Time) (int, error)

	// Delete a specific 'key' time bucket
	Delete(key string) error
}

Store respresents an interface of type of data store which gets implemented in different types, e.g. Redis, InMemory, etc.

Jump to

Keyboard shortcuts

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