private boolean checkCacheState(String blobKey, short lifeVersion, BlobState... desiredStates) {
    if (recentBlobCache == null) {
      return false;
    }
    // If the request is coming from frontend, and the desired states being checked are deleted/created (undelete),
    // then cache might not help. Operations like ttl update and put are once in lifetime of a blob. So a cache hit in
    // those cases definitely helps. A cache miss for ttl update or put, doesn't necessarily mean that we never saw
    // that operation for the given blob before. It only means that this cloud blob store instance didn't see it. For
    // this case, the pre<operation>Validation methods (e.g, {@code preDeleteValidation, preTtlUpdateValidation} etc)
    // will help do any validations if required.
    if (lifeVersion == MessageInfo.LIFE_VERSION_FROM_FRONTEND && !Collections.disjoint(Arrays.asList(desiredStates),
        Arrays.asList(BlobState.DELETED, BlobState.CREATED))) {
      return false;
    }
    // If we are here, in case of delete and undelete, we pass the life version to check against.
    // So this should be safe, as long as we claim a cache hit only when life version in cache is not older than
    // life version passed. Again this doesn't mean that a more recent life version was never seen for this blob. It
    // only means that this cloud blob store instance didn't see it. And for this case, the pre<operation>Validation
    // methods (e.g, {@code preDeleteValidation, preTtlUpdateValidation} etc) will help do any validations if required.
    BlobLifeState cachedState = recentBlobCache.get(blobKey);
    vcrMetrics.blobCacheLookupCount.inc();
    if (cachedState == null) {
      return false;
    }
    if (desiredStates == null || desiredStates.length == 0) {
      vcrMetrics.blobCacheHitCount.inc();
      return true;
    }
    for (BlobState desiredState : desiredStates) {
      if ((desiredState == cachedState.getBlobState() && (lifeVersion == IGNORE_LIFE_VERSION
          || lifeVersion <= cachedState.getLifeVersion()))
          || desiredState == BlobState.TTL_UPDATED && cachedState.isTtlUpdated()) {
        vcrMetrics.blobCacheHitCount.inc();
        return true;
      }
    }
    return false;
  }
Check the blob state in the recent blob cache against one or more desired states and life version.
@param blobKey the blob key to lookup.
@param lifeVersion the life version to check.
@param desiredStates the desired state(s) to check. If empty, any cached state is accepted.
@return true if the blob key is in the cache in one of the desired states and has appropriate life
version, otherwise false.
ambry-cloud/src/main/java/com/github/ambry/cloud/CloudBlobStore.java