cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2019 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultExpirationTime = time.Hour
	DefaultHeartbeatTime  = time.Minute
	CleanUpIntervalTime   = time.Minute
	CacheAPIHeaderName    = "X-Granblue-Cache-API"
)

Variables

This section is empty.

Functions

func GetKeyForRequest

func GetKeyForRequest(req *http.Request) string

func New

func New(config *ServerConfig) lib.Server

Types

type Cache

type Cache struct {
	StatusCode    int
	Status        string
	Header        http.Header
	Body          []byte
	ContentLength int64
}

type CacheReader

type CacheReader struct {
	Reader io.Reader
}

func (*CacheReader) Close

func (c *CacheReader) Close() error

func (*CacheReader) Read

func (c *CacheReader) Read(p []byte) (int, error)

type Server

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

func (*Server) Cache

func (s *Server) Cache(req *http.Request, res *http.Response, body []byte) error

func (*Server) CacheAsync

func (s *Server) CacheAsync(req *http.Request, res *http.Response, body []byte, callback func(error))

func (*Server) Close

func (s *Server) Close() error

func (*Server) Fetch

func (s *Server) Fetch(req *http.Request) (*http.Response, error)

func (*Server) FetchFromCache

func (s *Server) FetchFromCache(req *http.Request) (*http.Response, error)

func (*Server) FetchFromServer

func (s *Server) FetchFromServer(req *http.Request) (*http.Response, error)

func (*Server) FetchRawFromCache

func (s *Server) FetchRawFromCache(key string) ([]byte, error)

func (*Server) HasCache

func (s *Server) HasCache(req *http.Request) bool

func (*Server) Listener

func (s *Server) Listener() net.Listener

func (*Server) Open

func (s *Server) Open(addr string) (net.Listener, error)

func (*Server) RedisAvailable

func (s *Server) RedisAvailable() bool

func (*Server) Running

func (s *Server) Running() bool

func (*Server) ServeAsAPI

func (s *Server) ServeAsAPI(w http.ResponseWriter, req *http.Request)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Server) ServeHTTPUnsafe

func (s *Server) ServeHTTPUnsafe(w http.ResponseWriter, req *http.Request)

func (*Server) ShouldCache

func (s *Server) ShouldCache(req *http.Request, res *http.Response) bool

func (*Server) WaitGroup

func (s *Server) WaitGroup() *sync.WaitGroup

type ServerConfig

type ServerConfig struct {
	RedisAddr  string
	Redis      *redis.Client
	HttpClient *http.Client
}

Jump to

Keyboard shortcuts

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