mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
Fix concurrent map writes for FeedIcon cache
This commit is contained in:
parent
286cbff236
commit
a8d160f9b1
@ -177,7 +177,9 @@ func (s *Server) handleFeedIcon(c *router.Context) {
|
|||||||
bytes: *(*feed).Icon,
|
bytes: *(*feed).Icon,
|
||||||
etag: etag,
|
etag: etag,
|
||||||
}
|
}
|
||||||
|
s.cache_mutex.Lock()
|
||||||
s.cache[cachekey] = cachedat
|
s.cache[cachekey] = cachedat
|
||||||
|
s.cache_mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
icon := cachedat.(feedicon)
|
icon := cachedat.(feedicon)
|
||||||
|
@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/nkanaev/yarr/src/storage"
|
"github.com/nkanaev/yarr/src/storage"
|
||||||
"github.com/nkanaev/yarr/src/worker"
|
"github.com/nkanaev/yarr/src/worker"
|
||||||
@ -13,6 +14,7 @@ type Server struct {
|
|||||||
db *storage.Storage
|
db *storage.Storage
|
||||||
worker *worker.Worker
|
worker *worker.Worker
|
||||||
cache map[string]interface{}
|
cache map[string]interface{}
|
||||||
|
cache_mutex *sync.Mutex
|
||||||
|
|
||||||
BasePath string
|
BasePath string
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ func NewServer(db *storage.Storage, addr string) *Server {
|
|||||||
Addr: addr,
|
Addr: addr,
|
||||||
worker: worker.NewWorker(db),
|
worker: worker.NewWorker(db),
|
||||||
cache: make(map[string]interface{}),
|
cache: make(map[string]interface{}),
|
||||||
|
cache_mutex: &sync.Mutex{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user