You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// increaseSize is called after we have added a value to the cache to update
202
205
// the size of the current cache.
203
206
// We must ensure that we don't drop the value we just added.
204
207
// While it is technically ok to keep no value if max cache size is 0 (or memory size < of the size of one cluster)
205
208
// it will make recreate the value all the time.
206
209
// Let's be nice with our user and be tolerent to misconfiguration.
207
-
if (!extra_size) {
210
+
if (!extra_cost) {
208
211
// Don't try to remove an item if we have new size == 0.
209
212
// This is the case when concurent cache add a future without value.
210
213
// We will handle the real increase size when concurent cache will directly call us.
211
214
return;
212
215
}
213
-
_current_size += extra_size;
214
-
while (_current_size > _max_size && _cache_items_list.size() > 1) {
216
+
_current_cost += extra_cost;
217
+
while (_current_cost > _max_cost && size() > 1) {
215
218
dropLast();
216
219
}
217
220
}
218
221
219
-
voiddecreaseSize(size_tsizeToRemove) {
220
-
if (sizeToRemove > _current_size) {
221
-
std::cerr << "WARNING: We have detected inconsistant cache management, trying to remove " << sizeToRemove << " from a cache with size " << _current_size << std::endl;
222
+
voiddecreaseCost(size_tcostToRemove) {
223
+
if (costToRemove > _current_cost) {
224
+
std::cerr << "WARNING: We have detected inconsistant cache management, trying to remove " << costToRemove << " from a cache with size " << _current_cost << std::endl;
222
225
std::cerr << "Please open an issue on https://github.com/openzim/libzim/issues with this message and the zim file you use" << std::endl;
0 commit comments