| 301 | } |
| 302 | |
| 303 | Action * |
| 304 | Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type, const char *hostname, int host_len) const |
| 305 | { |
| 306 | if (!CacheProcessor::IsCacheReady(type)) { |
| 307 | cont->handleEvent(CACHE_EVENT_LOOKUP_FAILED, nullptr); |
| 308 | return ACTION_RESULT_DONE; |
| 309 | } |
| 310 | |
| 311 | StripeSM *stripe = key_to_stripe(key, hostname, host_len); |
| 312 | CacheVC *c = new_CacheVC(cont); |
| 313 | SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); |
| 314 | c->vio.op = VIO::READ; |
| 315 | c->op_type = static_cast<int>(CacheOpType::Lookup); |
| 316 | ts::Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); |
| 317 | ts::Metrics::Gauge::increment(stripe->cache_vol->vol_rsb.status[c->op_type].active); |
| 318 | c->first_key = c->key = *key; |
| 319 | c->frag_type = type; |
| 320 | c->f.lookup = 1; |
| 321 | c->stripe = stripe; |
| 322 | c->last_collision = nullptr; |
| 323 | |
| 324 | if (c->handleEvent(EVENT_INTERVAL, nullptr) == EVENT_CONT) { |
| 325 | return &c->_action; |
| 326 | } else { |
| 327 | return ACTION_RESULT_DONE; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | Action * |
| 332 | Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, const char *hostname, int host_len) const |