From f07672f5c3cad2e73596ab3d7ca16660f6881df6 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Mon, 24 Jul 2017 13:36:41 +0200 Subject: plumbing/cache: use more explicit interface * renamed Add to Put * Get returns a second bool value to indicate if there was hit or miss. --- plumbing/cache/common.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'plumbing/cache/common.go') diff --git a/plumbing/cache/common.go b/plumbing/cache/common.go index 7b90c55..9efc26c 100644 --- a/plumbing/cache/common.go +++ b/plumbing/cache/common.go @@ -11,8 +11,14 @@ const ( type FileSize int64 +// Object is an interface to a object cache. type Object interface { - Add(o plumbing.EncodedObject) - Get(k plumbing.Hash) plumbing.EncodedObject + // Put puts the given object into the cache. Whether this object will + // actually be put into the cache or not is implementation specific. + Put(o plumbing.EncodedObject) + // Get gets an object from the cache given its hash. The second return value + // is true if the object was returned, and false otherwise. + Get(k plumbing.Hash) (plumbing.EncodedObject, bool) + // Clear clears every object from the cache. Clear() } -- cgit