}
int64_t
-MemObject::policyLowestOffsetToKeep() const
+MemObject::policyLowestOffsetToKeep(bool swap) const
{
/*
* Careful. lowest_offset can be greater than endOffset(), such
if (endOffset() < lowest_offset ||
endOffset() - inmem_lo > (int64_t)Config.Store.maxInMemObjSize ||
- !Config.onoff.memory_cache_first)
+ (swap && !Config.onoff.memory_cache_first))
return lowest_offset;
return inmem_lo;
void
MemObject::trimSwappable()
{
- int64_t new_mem_lo = policyLowestOffsetToKeep();
+ int64_t new_mem_lo = policyLowestOffsetToKeep(1);
/*
* We should only free up to what we know has been written
* to disk, not what has been queued for writing. Otherwise
void
MemObject::trimUnSwappable()
{
- int64_t new_mem_lo = policyLowestOffsetToKeep();
+ int64_t new_mem_lo = policyLowestOffsetToKeep(0);
assert (new_mem_lo > 0);
data_hdr.freeDataUpto(new_mem_lo);
* better
*/
int64_t objectBytesOnDisk() const;
- int64_t policyLowestOffsetToKeep() const;
+ int64_t policyLowestOffsetToKeep(bool swap) const;
void trimSwappable();
void trimUnSwappable();
bool isContiguous() const;
if (!token)
self_destruct();
- if (strcmp(token, "always")) {
+ if (strcmp(token, "always") == 0) {
Config.onoff.memory_cache_first = 1;
Config.onoff.memory_cache_disk = 1;
- } else if (strcmp(token, "disk")) {
+ } else if (strcmp(token, "disk") == 0) {
Config.onoff.memory_cache_first = 0;
Config.onoff.memory_cache_disk = 1;
} else if (strncmp(token, "net", 3) == 0) {
Config.onoff.memory_cache_first = 1;
Config.onoff.memory_cache_disk = 0;
- } else if (strncmp(token, "none", 3) == 0) {
+ } else if (strcmp(token, "never") == 0) {
Config.onoff.memory_cache_first = 0;
Config.onoff.memory_cache_disk = 0;
} else
if (mem_status == IN_MEMORY)
return;
- if (mem_obj->policyLowestOffsetToKeep() == 0)
- /* Nothing to do */
- return;
-
if (!swapOutAble()) {
+ if (mem_obj->policyLowestOffsetToKeep(0) == 0) {
+ /* Nothing to do */
+ return;
+ }
/*
* Its not swap-able, and we're about to delete a chunk,
* so we must make it PRIVATE. This is tricky/ugly because