MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / DecrementInt8

Method DecrementInt8

pkg/util/cache/cache.go:661–678  ·  view source on GitHub ↗

Decrement an item of type int8 by n. Returns an error if the item's value is not an int8, or if it was not found. If there is no error, the decremented value is returned.

(k string, n int8)

Source from the content-addressed store, hash-verified

659// not an int8, or if it was not found. If there is no error, the decremented
660// value is returned.
661func (c *cache) DecrementInt8(k string, n int8) (int8, error) {
662 c.mu.Lock()
663 v, found := c.items[k]
664 if !found || v.Expired() {
665 c.mu.Unlock()
666 return 0, fmt.Errorf("Item %s not found", k)
667 }
668 rv, ok := v.Object.(int8)
669 if !ok {
670 c.mu.Unlock()
671 return 0, fmt.Errorf("The value for %s is not an int8", k)
672 }
673 nv := rv - n
674 v.Object = nv
675 c.items[k] = v
676 c.mu.Unlock()
677 return nv, nil
678}
679
680// Decrement an item of type int16 by n. Returns an error if the item's value is
681// not an int16, or if it was not found. If there is no error, the decremented

Callers 1

TestDecrementInt8Function · 0.80

Calls 3

LockMethod · 0.80
ExpiredMethod · 0.80
ErrorfMethod · 0.80

Tested by 1

TestDecrementInt8Function · 0.64