MCPcopy Create free account
hub / github.com/dadgar/onecache / parse

Method parse

onecache/memcache_handlers.go:122–164  ·  view source on GitHub ↗
(flags []string)

Source from the content-addressed store, hash-verified

120}
121
122func (h *casHandler) parse(flags []string) error {
123 l := len(flags)
124 if l != 5 && l != 6 {
125 return fmt.Errorf("received an unexpected number of flags (%d); expect %v", l, expectedCasInput)
126 }
127
128 h.args.Key = flags[0]
129
130 flag, err := strconv.ParseInt(flags[1], 10, 32)
131 if err != nil {
132 return fmt.Errorf("could not parse flag field: %v", err)
133 }
134 h.args.Flags = int32(flag)
135
136 exp, err := strconv.ParseInt(flags[2], 10, 32)
137 if err != nil {
138 return fmt.Errorf("could not parse expiration field: %v", err)
139 return err
140 }
141 h.args.Exp = convertMemcacheExpToUnix(int32(exp))
142
143 bytes, err := strconv.ParseInt(flags[3], 10, 64)
144 if err != nil {
145 return fmt.Errorf("could not parse bytes field: %v", err)
146 }
147 h.size = bytes
148
149 cas, err := strconv.ParseInt(flags[4], 10, 64)
150 if err != nil {
151 return fmt.Errorf("could not parse cas field: %v", err)
152 }
153 h.args.Cas = cas
154
155 if l == 6 {
156 if flags[5] != noreply {
157 return fmt.Errorf("was expecting %v; got %v", noreply, flags[5])
158 }
159
160 h.noReply = true
161 }
162
163 return nil
164}
165
166func (h *casHandler) readBytes() int64 {
167 return h.size

Callers

nothing calls this directly

Calls 1

convertMemcacheExpToUnixFunction · 0.85

Tested by

no test coverage detected