MCPcopy Index your code
hub / github.com/SpectoLabs/hoverfly / Get

Method Get

core/cache/boltdb_cache.go:43–65  ·  view source on GitHub ↗

Get - searches for given key in the cache and returns value if found

(key []byte)

Source from the content-addressed store, hash-verified

41
42// Get - searches for given key in the cache and returns value if found
43func (c *BoltCache) Get(key []byte) (value []byte, err error) {
44
45 err = c.DS.View(func(tx *bolt.Tx) error {
46 bucket := tx.Bucket(c.CurrentBucket)
47 if bucket == nil {
48 return fmt.Errorf("Bucket %q not found!", c.CurrentBucket)
49 }
50 // "Byte slices returned from Bolt are only valid during a transaction."
51 var buffer bytes.Buffer
52 val := bucket.Get(key)
53
54 // If it doesn't exist then it will return nil
55 if val == nil {
56 return fmt.Errorf("key %q not found \n", key)
57 }
58
59 buffer.Write(val)
60 value = buffer.Bytes()
61 return nil
62 })
63
64 return
65}
66
67// GetAllValues - returns all values
68func (c *BoltCache) GetAllValues() (values [][]byte, err error) {

Callers

nothing calls this directly

Calls 2

ViewMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected