Source File
cache.go
Belonging Package
github.com/pancsta/go-app/pkg/app
package appimport ()type cacheItem struct {// The request path.Path string// The response content type.ContentType string// The response content encoding.ContentEncoding string// The response body.Body []byte}func ( cacheItem) () int {return len(.Body)}type memoryCache struct {mu sync.RWMutexitems map[string]cacheItem}func newMemoryCache( int) *memoryCache {return &memoryCache{items: make(map[string]cacheItem, ),}}func ( *memoryCache) ( cacheItem) {.mu.Lock().items[.Path] =.mu.Unlock()}func ( *memoryCache) ( string) (cacheItem, bool) {.mu.Lock(), := .items[].mu.Unlock()return ,}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |