Documentation ¶
Index ¶
- func GetGroupCachePool() *groupcache.HTTPPool
- func InitGroupCacheRes(maxSize int) error
- func InitRedisClient(addr, password string, db int) error
- func NewNoPreCollectError(msg string) error
- func ParseRedisConfig(connSetting string) (*redis.Options, error)
- func ReleaseGroupCacheRes() error
- type Backend
- func NewFileBackend(path string) (Backend, error)
- func NewInMemoryBackend(ctx context.Context, key string, expiration time.Time) (Backend, error)
- func NewRedisBackend(ctx context.Context, key string, expiration time.Time) (Backend, error)
- func WrapResponseWriterToBackend(w http.ResponseWriter) Backend
- type Base
- type FileBackend
- type FileReader
- type InMemoryBackend
- type NoPreCollectError
- type RedisBackend
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGroupCachePool ¶ added in v0.3.0
func GetGroupCachePool() *groupcache.HTTPPool
GetGroupCachePool gets the groupcache's httpool
func InitGroupCacheRes ¶
InitGroupCacheRes init the resources for groupcache init this in the handler provision stage.
func InitRedisClient ¶ added in v0.2.0
InitRedisClient init the client for the redis
func NewNoPreCollectError ¶ added in v0.3.3
NewNoPreCollectError new a NoPreCollectError error
func ParseRedisConfig ¶ added in v0.3.0
ParseRedisConfig prases the connection settings string from the caddyfile
func ReleaseGroupCacheRes ¶ added in v0.3.0
func ReleaseGroupCacheRes() error
ReleaseGroupCacheRes releases the rousources the memory backend collects
Types ¶
type Backend ¶
type Backend interface { io.Writer io.Closer Length() int Clean() error Flush() error GetReader() (io.ReadCloser, error) }
Backend is the cache storage backend.
func NewFileBackend ¶
NewFileBackend new a disk storage backend
func NewInMemoryBackend ¶
NewInMemoryBackend get the singleton of groupcache
func NewRedisBackend ¶ added in v0.2.0
NewRedisBackend new a redis backend for cache's storage
func WrapResponseWriterToBackend ¶
func WrapResponseWriterToBackend(w http.ResponseWriter) Backend
WrapResponseWriterToBackend wrap the responseWriter to match the backend's interface
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base wraps the http.ResponseWriter to match the Backend interface
func (*Base) GetReader ¶
func (b *Base) GetReader() (io.ReadCloser, error)
GetReader no reader for base backend
type FileBackend ¶
type FileBackend struct {
// contains filtered or unexported fields
}
FileBackend saves the content into a file
func (*FileBackend) GetReader ¶
func (f *FileBackend) GetReader() (io.ReadCloser, error)
GetReader get the ReadCloser from the file backend
func (*FileBackend) Length ¶ added in v0.3.3
func (f *FileBackend) Length() int
Length return the cache content's length
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
FileReader is the common code to read the storages until the subscription channel is closed
type InMemoryBackend ¶
type InMemoryBackend struct { Ctx context.Context Key string // contains filtered or unexported fields }
InMemoryBackend saves the content into inmemory with the groupcache.
func (*InMemoryBackend) Clean ¶
func (i *InMemoryBackend) Clean() error
Clean performs the purge storage
func (*InMemoryBackend) Close ¶
func (i *InMemoryBackend) Close() error
Close writeh the temp buffer's content to the groupcache
func (*InMemoryBackend) GetReader ¶
func (i *InMemoryBackend) GetReader() (io.ReadCloser, error)
GetReader return a reader for the write public response
func (*InMemoryBackend) Length ¶ added in v0.3.3
func (i *InMemoryBackend) Length() int
Length return the cache content's length
type NoPreCollectError ¶ added in v0.3.3
type NoPreCollectError struct {
Content string
}
NoPreCollectError is a custom error when there is no precollect content in memory cache.
func (NoPreCollectError) Error ¶ added in v0.3.3
func (e NoPreCollectError) Error() string
Error return the error message
type RedisBackend ¶
type RedisBackend struct { Ctx context.Context Key string // contains filtered or unexported fields }
RedisBackend saves the content into redis
func (*RedisBackend) Clean ¶ added in v0.2.0
func (r *RedisBackend) Clean() error
Clean performs the purge storage
func (*RedisBackend) Close ¶ added in v0.2.0
func (r *RedisBackend) Close() error
Close writeh the temp buffer's content to the groupcache
func (*RedisBackend) Flush ¶ added in v0.2.0
func (r *RedisBackend) Flush() error
Flush do nothing here
func (*RedisBackend) GetReader ¶ added in v0.2.0
func (r *RedisBackend) GetReader() (io.ReadCloser, error)
GetReader return a reader for the write public response
func (*RedisBackend) Length ¶ added in v0.3.3
func (r *RedisBackend) Length() int
Length return the cache content's length
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription ..
func NewSubscription ¶
func NewSubscription() *Subscription
func (*Subscription) NewSubscriber ¶
func (s *Subscription) NewSubscriber() <-chan int
func (*Subscription) NotifyAll ¶
func (s *Subscription) NotifyAll(newBytes int)
NotifyAll notify all subscribers with the signal
func (*Subscription) RemoveSubscriber ¶
func (s *Subscription) RemoveSubscriber(subscriber <-chan int)
RemoveSubscriber remove the subscriber from the list
func (*Subscription) WaitAll ¶
func (s *Subscription) WaitAll()
WaitAll waits all subscription are closed