MCPcopy Create free account
hub / github.com/acl-dev/acl / set

Method set

lib_acl_cpp/src/memcache/memcache.cpp:121–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121bool memcache::set(const string& key, const void* dat, size_t dlen,
122 time_t timeout, unsigned short flags)
123{
124 bool has_tried = false;
125 struct iovec v[3];
126 req_line_.format("set %s %u %d %d\r\n", key.c_str(),
127 flags, (int) timeout, (int) dlen);
128AGAIN:
129 if (!open()) {
130 return false;
131 }
132
133#ifdef MINGW
134 v[0].iov_base = (char*) req_line_.c_str();
135#else
136 v[0].iov_base = (void*) req_line_.c_str();
137#endif
138 v[0].iov_len = req_line_.length();
139#ifdef MINGW
140 v[1].iov_base = (char*) dat;
141#else
142 v[1].iov_base = (void*) dat;
143#endif
144 v[1].iov_len = dlen;
145#ifdef MINGW
146 v[2].iov_base = (char*) "\r\n";
147#else
148 v[2].iov_base = (void*) "\r\n";
149#endif
150 v[2].iov_len = 2;
151
152 if (conn_->writev(v, 3) < 0) {
153 close();
154 if (retry_ && !has_tried) {
155 has_tried = true;
156 goto AGAIN;
157 }
158 ebuf_.format("write set(%s) error", key.c_str());
159 return false;
160 }
161
162 if (!conn_->gets(res_line_)) {
163 close();
164 if (retry_ && !has_tried) {
165 has_tried = true;
166 goto AGAIN;
167 }
168 ebuf_.format("reply for set(%s) error", key.c_str());
169 return false;
170 }
171
172 if (res_line_.compare("STORED", false) != 0) {
173 close();
174 if (retry_ && !has_tried) {
175 has_tried = true;
176 goto AGAIN;
177 }
178 ebuf_.format("reply(%s) for set(%s) error",

Callers

nothing calls this directly

Calls 10

openFunction · 0.85
setFunction · 0.85
writevMethod · 0.80
getsMethod · 0.80
compareMethod · 0.80
closeFunction · 0.50
getFunction · 0.50
formatMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected