MCPcopy Create free account
hub / github.com/kataras/iris / Decrement

Method Decrement

sessions/session.go:277–282  ·  view source on GitHub ↗

Decrement decrements the stored int value saved as "key" by -"n". If value doesn't exist on that "key" then it creates one with the "n" as its value. It returns the new, decremented, value even if it's less than zero.

(key string, n int)

Source from the content-addressed store, hash-verified

275// If value doesn't exist on that "key" then it creates one with the "n" as its value.
276// It returns the new, decremented, value even if it's less than zero.
277func (s *Session) Decrement(key string, n int) (newValue int) {
278 newValue = s.GetIntDefault(key, 0)
279 newValue -= n
280 s.Set(key, newValue)
281 return
282}
283
284// GetInt64 same as `Get` but returns its int64 representation,
285// if key doesn't exist then it returns -1 and a non-nil error.

Callers

nothing calls this directly

Calls 2

GetIntDefaultMethod · 0.95
SetMethod · 0.95

Tested by

no test coverage detected