server

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServerPort is the default port for the server
	DefaultServerPort = 6379
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Cache is the actual cache
	Cache *gocache.Cache

	// Port is the port that the server will listen on
	Port int

	// AutoSaveInterval is the interval at which the server will automatically save the Cache
	AutoSaveInterval time.Duration

	// AutoSaveFile is the file in which the cache will be persisted every AutoSaveInterval
	AutoSaveFile string
	// contains filtered or unexported fields
}

Server is a cache server using gocache as cache and RESP (Redis bindings) as server

func NewServer

func NewServer(cache *gocache.Cache) *Server

NewServer creates a new cache server

func (*Server) Start

func (server *Server) Start() error

Start starts the cache server, which includes the autosave

This is a blocking function, therefore, you are expected to run this on a goroutine

func (*Server) Stop

func (server *Server) Stop() error

Stop closes the Server

func (*Server) WithAutoSave

func (server *Server) WithAutoSave(interval time.Duration, file string) *Server

WithAutoSave allows the configuration of the automatic saving feature. Note that setting this will also cause the server to immediately read the file passed and populate the cache

Disabled if set to 0

func (*Server) WithPort

func (server *Server) WithPort(port int) *Server

WithPort sets the port of the server

Jump to

Keyboard shortcuts

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