Documentation ¶
Overview ¶
package proxycache is a key-value caching library.
Index ¶
- type ProxyCache
- func (p *ProxyCache) Get(key string) []byte
- func (p *ProxyCache) HTTPHandlerV1() http.Handler
- func (p *ProxyCache) Put(key string, value []byte, ttw int64)
- func (p *ProxyCache) SetLoadMaxProc(maxProc int)
- func (p *ProxyCache) SetMaxEntry(maxEntry int)
- func (p *ProxyCache) SetSaveProc(proc int)
- func (p *ProxyCache) Status() []byte
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProxyCache ¶
type ProxyCache struct {
// contains filtered or unexported fields
}
ProxyCache is an in-memory key-value cache, and a database access proxy.
func New ¶
func New(p proxy.Proxy, maxEntry, saverProc, loaderProc int) *ProxyCache
New creates a ProxyCache.
func (*ProxyCache) Get ¶
func (p *ProxyCache) Get(key string) []byte
Get retrieves data from ProxyCache. If provided key is not found in cache, data will be loaded by calling Proxy's Load method.
func (*ProxyCache) HTTPHandlerV1 ¶
func (p *ProxyCache) HTTPHandlerV1() http.Handler
HTTPHandlerV1 create HTTP handler (version 1). To serve on a sub URI, don't forget to use http.StripPrefix(). Check example/server for more details.
func (*ProxyCache) Put ¶
func (p *ProxyCache) Put(key string, value []byte, ttw int64)
Put puts data into ProxyCache. Data will be saved asynchronously by calling Proxy's Save method.
func (*ProxyCache) SetLoadMaxProc ¶
func (p *ProxyCache) SetLoadMaxProc(maxProc int)
SetLoadMaxProc sets Loader's maxProc.
func (*ProxyCache) SetMaxEntry ¶
func (p *ProxyCache) SetMaxEntry(maxEntry int)
SetMaxEntry sets Cache's maxEntry.
func (*ProxyCache) SetSaveProc ¶
func (p *ProxyCache) SetSaveProc(proc int)
SetSaveProc sets the number of Saver's workers.
func (*ProxyCache) Status ¶
func (p *ProxyCache) Status() []byte
Status returns ProxyCache's runtime performance status.
type Status ¶
type Status struct { cache.CacheStatus cache.BufferStatus proxy.LoaderStatus proxy.SaverStatus }
Status is used for runtime performance profiling.
Directories ¶
Path | Synopsis |
---|---|
package cache defines containers for in-memory storage.
|
package cache defines containers for in-memory storage. |
example
|
|
package lru implements an LRU queue.
|
package lru implements an LRU queue. |
priority-queue
|
|
pq
package pq implements a priority queue.
|
package pq implements a priority queue. |
package proxy defines the Proxy interface which should be implemented by package user.
|
package proxy defines the Proxy interface which should be implemented by package user. |