MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / BuildCacheEntry

Method BuildCacheEntry

core/predictor/framework/request_cache.cpp:128–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128int RequestCache::BuildCacheEntry(const Response& res, CacheEntry* entry) {
129 if (entry == nullptr) {
130 return -1;
131 }
132 std::lock_guard<std::recursive_mutex> lk(cache_mtx_);
133 int size = res.ByteSize();
134 if (size >= cache_size_) {
135 LOG(INFO) << "res size[" << size << "] larger than cache_size["
136 << cache_size_ << "]";
137 return -1;
138 }
139 while (size > GetFreeCacheSize()) {
140 if (RemoveOne() != 0) {
141 LOG(ERROR) << "RemoveOne failed so can not build entry";
142 return -1;
143 }
144 }
145 entry->buf_ = res.SerializeAsString();
146 used_size_ += size;
147 return 0;
148}
149
150void RequestCache::UpdateLru(uint64_t key) {
151 std::lock_guard<std::recursive_mutex> lk(cache_mtx_);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected