mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
pkg/api: use a rwlock when accessing storage
The original patch used a mutex, however, the workload patterns are likely to be read-heavy, so use a rwlock instead.
This commit is contained in:
@@ -35,7 +35,7 @@ type BlobUpload struct {
|
||||
// ImageStore provides the image storage operations.
|
||||
type ImageStore struct {
|
||||
rootDir string
|
||||
lock *sync.Mutex
|
||||
lock *sync.RWMutex
|
||||
blobUploads map[string]BlobUpload
|
||||
log zerolog.Logger
|
||||
}
|
||||
@@ -43,7 +43,7 @@ type ImageStore struct {
|
||||
// NewImageStore returns a new image store backed by a file storage.
|
||||
func NewImageStore(rootDir string, log zlog.Logger) *ImageStore {
|
||||
is := &ImageStore{rootDir: rootDir,
|
||||
lock: &sync.Mutex{},
|
||||
lock: &sync.RWMutex{},
|
||||
blobUploads: make(map[string]BlobUpload),
|
||||
log: log.With().Caller().Logger(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user