Skip to content

Commit

Permalink
Merge pull request #78 from willscott/fix/cachehandlersize
Browse files Browse the repository at this point in the history
Add warning when caching handler is given too low limits
  • Loading branch information
willscott committed Oct 24, 2023
2 parents 41b3696 + 2f08e86 commit c6fdd71
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions helpers/cachinghandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ import (

// NewCachingHandler wraps a handler to provide a basic to/from-file handle cache.
func NewCachingHandler(h nfs.Handler, limit int) nfs.Handler {
cache, _ := lru.New[uuid.UUID, entry](limit)
verifiers, _ := lru.New[uint64, verifier](limit)
return &CachingHandler{
Handler: h,
activeHandles: cache,
activeVerifiers: verifiers,
cacheLimit: limit,
}
return NewCachingHandlerWithVerifierLimit(h, limit, limit)
}

// NewCachingHandlerWithVerifierLimit provides a basic to/from-file handle cache that can be tuned with a smaller cache of active directory listings.
func NewCachingHandlerWithVerifierLimit(h nfs.Handler, limit int, verifierLimit int) nfs.Handler {
if limit < 2 || verifierLimit < 2 {
nfs.Log.Warnf("Caching handler created with insufficient cache to support directory listing", "size", limit, "verifiers", verifierLimit)
}
cache, _ := lru.New[uuid.UUID, entry](limit)
verifiers, _ := lru.New[uint64, verifier](verifierLimit)
return &CachingHandler{
Expand Down

0 comments on commit c6fdd71

Please sign in to comment.