MCPcopy Create free account
hub / github.com/distributedio/titan / Incr

Method Incr

db/string.go:154–170  ·  view source on GitHub ↗

Incr increments the integer value by the given amount the old value must be integer

(delta int64)

Source from the content-addressed store, hash-verified

152// Incr increments the integer value by the given amount
153// the old value must be integer
154func (s *String) Incr(delta int64) (int64, error) {
155 value := s.Meta.Value
156 if value != nil {
157 v, err := strconv.ParseInt(string(value), 10, 64)
158 if err != nil {
159 return 0, ErrInteger
160 }
161 delta = v + delta
162 }
163
164 vs := strconv.FormatInt(delta, 10)
165 if err := s.Set([]byte(vs)); err != nil {
166 return 0, err
167 }
168 return delta, nil
169
170}
171
172// Incrf increments the float value by the given amount
173// the old value must be float

Callers 5

IncrFunction · 0.80
IncrByFunction · 0.80
DecrFunction · 0.80
DecrByFunction · 0.80
TestStringIncrFunction · 0.80

Calls 1

SetMethod · 0.95

Tested by 1

TestStringIncrFunction · 0.64