Debian Codegraph @

plumbing/cache/common.go

raw
1 package cache
2
3 import "github.com/go-git/go-git/v5/plumbing"
4
5 const (
6 Byte FileSize = 1 << (iota * 10)
7 KiByte
8 MiByte
9 GiByte
10 )
11
12 type FileSize int64
13
14 const DefaultMaxSize FileSize = 96 * MiByte
15
16 // Object is an interface to a object cache.
17 type Object interface {
18 // Put puts the given object into the cache. Whether this object will
19 // actually be put into the cache or not is implementation specific.
20 Put(o plumbing.EncodedObject)
21 // Get gets an object from the cache given its hash. The second return value
22 // is true if the object was returned, and false otherwise.
23 Get(k plumbing.Hash) (plumbing.EncodedObject, bool)
24 // Clear clears every object from the cache.
25 Clear()
26 }
27
28 // Buffer is an interface to a buffer cache.
29 type Buffer interface {
30 // Put puts a buffer into the cache. If the buffer is already in the cache,
31 // it will be marked as used. Otherwise, it will be inserted. Buffer might
32 // be evicted to make room for the new one.
33 Put(key int64, slice []byte)
34 // Get returns a buffer by its key. It marks the buffer as used. If the
35 // buffer is not in the cache, (nil, false) will be returned.
36 Get(key int64) ([]byte, bool)
37 // Clear clears every object from the cache.
38 Clear()
39 }