diff options
author | Santiago M. Mola <santi@mola.io> | 2017-02-27 17:14:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-27 17:14:54 +0100 |
commit | 0e9dea19f856e256e609c3390e000760d2b2b95a (patch) | |
tree | 1b50b78030d8d382da71166eb9d280be371b45bd /plumbing/cache/object.go | |
parent | a8f1e517e302569f11fced521c3f091997dac147 (diff) | |
parent | ae887c94d02661a91814fa05b4b54ba723220e6b (diff) | |
download | go-git-0e9dea19f856e256e609c3390e000760d2b2b95a.tar.gz |
Merge pull request #289 from ajnavarro/documentation/cache
plumbing/cache: specify units in memory size (Fix #234)
Diffstat (limited to 'plumbing/cache/object.go')
-rw-r--r-- | plumbing/cache/object.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/plumbing/cache/object.go b/plumbing/cache/object.go index 47e390b..f1af4e3 100644 --- a/plumbing/cache/object.go +++ b/plumbing/cache/object.go @@ -11,13 +11,13 @@ type ObjectFIFO struct { objects map[plumbing.Hash]plumbing.EncodedObject order *queue - maxSize int64 - actualSize int64 + maxSize FileSize + actualSize FileSize } // NewObjectFIFO returns an Object cache that keeps the newest objects that fit // into the specific memory size -func NewObjectFIFO(size int64) *ObjectFIFO { +func NewObjectFIFO(size FileSize) *ObjectFIFO { return &ObjectFIFO{ objects: make(map[plumbing.Hash]plumbing.EncodedObject), order: newQueue(initialQueueSize), @@ -30,7 +30,7 @@ func NewObjectFIFO(size int64) *ObjectFIFO { func (c *ObjectFIFO) Add(o plumbing.EncodedObject) { // if the size of the object is bigger or equal than the cache size, // skip it - if o.Size() >= c.maxSize { + if FileSize(o.Size()) >= c.maxSize { return } @@ -44,14 +44,14 @@ func (c *ObjectFIFO) Add(o plumbing.EncodedObject) { h := c.order.Pop() o := c.objects[h] if o != nil { - c.actualSize -= o.Size() + c.actualSize -= FileSize(o.Size()) delete(c.objects, h) } } c.objects[o.Hash()] = o c.order.Push(o.Hash()) - c.actualSize += o.Size() + c.actualSize += FileSize(o.Size()) } // Get returns an object by his hash. If the object is not found in the cache, it |