syntax fixes
This commit is contained in:
parent
8e748aaa90
commit
1ce33aa89a
13 changed files with 45 additions and 43 deletions
14
pkg/cache/cache.go
vendored
14
pkg/cache/cache.go
vendored
|
|
@ -14,7 +14,7 @@ type CachedPage struct {
|
|||
}
|
||||
|
||||
type Cache struct {
|
||||
sync.RWMutex
|
||||
mu sync.RWMutex
|
||||
Cache map[string]*CachedPage
|
||||
}
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ func NewCache() *Cache {
|
|||
|
||||
func (c *Cache) Add(title string, p *core.Page) {
|
||||
now := time.Now()
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
cp, ok := c.Cache[title]
|
||||
if ok && now.After(cp.CacheTime) {
|
||||
cp.Page = p
|
||||
|
|
@ -37,8 +37,8 @@ func (c *Cache) Add(title string, p *core.Page) {
|
|||
}
|
||||
|
||||
func (c *Cache) Get(title string) (p *core.Page) {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
if cp, ok := c.Cache[title]; ok {
|
||||
p = new(core.Page)
|
||||
*p = *cp.Page
|
||||
|
|
@ -48,7 +48,7 @@ func (c *Cache) Get(title string) (p *core.Page) {
|
|||
}
|
||||
|
||||
func (c *Cache) Delete(title string) {
|
||||
c.Lock()
|
||||
c.mu.Lock()
|
||||
delete(c.Cache, title)
|
||||
c.Unlock()
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue