You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.go 1.2KB

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