// Path: src/main/java/org/iq80/memory/Region.java
// public interface Region
// {
//     Allocator getAllocator();
// 
//     ByteBuffer toByteBuffer();
// 
//     long getAddress();
// 
//     long size();
// 
//     byte getByte(long offset);
// 
//     void putByte(long offset, byte value);
// 
//     byte[] getBytes(long srcOffset, int length);
// 
//     void getBytes(long srcOffset, byte[] target);
// 
//     void getBytes(long srcOffset, byte[] target, int targetOffset, int length);
// 
//     void putBytes(long targetOffset, byte[] src);
// 
//     void putBytes(long targetOffset, byte[] src, int srcOffset, int length);
// 
//     Region getRegion(long offset);
// 
//     Region getRegion(long offset, long length);
// 
//     short getShort(long offset);
// 
//     void putShort(long offset, short value);
// 
//     char getChar(long offset);
// 
//     void putChar(long offset, char value);
// 
//     int getInt(long offset);
// 
//     void putInt(long offset, int value);
// 
//     long getLong(long offset);
// 
//     void putLong(long offset, long value);
// 
//     float getFloat(long offset);
// 
//     void putFloat(long offset, float value);
// 
//     double getDouble(long offset);
// 
//     void putDouble(long offset, double value);
// 
//     void setMemory(byte value);
// 
//     void setMemory(long offset, long size, byte value);
// 
//     void copyMemory(long srcOffset, Region target);
// 
//     void copyMemory(long srcOffset, Region target, long targetOffset, long size);
// 
//     int compareMemory(long srcOffset, Region target, long targetOffset, long size);
// 
//     boolean isInBounds(long offset, long length);
// 
//     void checkBounds(long offset, long length);
// 
// }


import org.iq80.memory.Region;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

        // try to allocate again
        // maybe someone else freed some stuff
        item = Item.createItem(totalLength, slabManager, useCas);
        if (item != null) {
            return item;
        }

        // Last ditch effort. There is a very rare bug which causes
        // refcount leaks. We've fixed most of them, but it still happens,
        // and it may happen in the future.
        // We can reasonably assume no item can stay locked for more than
        // three hours, so if we find one in the tail which is that old,
        // free it anyway.
        item = lru.tryTailRepair(50, current_time);
        if (item != null) {
            // remove from hash
            assoc.delete(item.getKey());

            return item;
        }

        item = Item.createItem(totalLength, slabManager, useCas);
        return item;
    }

    /**
     * Get with expiriation logic. wrapper around assoc_find which does the lazy
     * expiration logic
     */
// Path: src/main/java/org/iq80/memory/Region.java
// public interface Region
// {
//     Allocator getAllocator();
// 
//     ByteBuffer toByteBuffer();
// 
//     long getAddress();
// 
//     long size();
// 
//     byte getByte(long offset);
// 
//     void putByte(long offset, byte value);
// 
//     byte[] getBytes(long srcOffset, int length);
// 
//     void getBytes(long srcOffset, byte[] target);
// 
//     void getBytes(long srcOffset, byte[] target, int targetOffset, int length);
// 
//     void putBytes(long targetOffset, byte[] src);
// 
//     void putBytes(long targetOffset, byte[] src, int srcOffset, int length);
// 
//     Region getRegion(long offset);
// 
//     Region getRegion(long offset, long length);
// 
//     short getShort(long offset);
// 
//     void putShort(long offset, short value);
// 
//     char getChar(long offset);
// 
//     void putChar(long offset, char value);
// 
//     int getInt(long offset);
// 
//     void putInt(long offset, int value);
// 
//     long getLong(long offset);
// 
//     void putLong(long offset, long value);
// 
//     float getFloat(long offset);
// 
//     void putFloat(long offset, float value);
// 
//     double getDouble(long offset);
// 
//     void putDouble(long offset, double value);
// 
//     void setMemory(byte value);
// 
//     void setMemory(long offset, long size, byte value);
// 
//     void copyMemory(long srcOffset, Region target);
// 
//     void copyMemory(long srcOffset, Region target, long targetOffset, long size);
// 
//     int compareMemory(long srcOffset, Region target, long targetOffset, long size);
// 
//     boolean isInBounds(long offset, long length);
// 
//     void checkBounds(long offset, long length);
// 
// }


// Path: src/main/java/org/iq80/memcached/Items.java
import org.iq80.memory.Region;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;


        // try to allocate again
        // maybe someone else freed some stuff
        item = Item.createItem(totalLength, slabManager, useCas);
        if (item != null) {
            return item;
        }

        // Last ditch effort. There is a very rare bug which causes
        // refcount leaks. We've fixed most of them, but it still happens,
        // and it may happen in the future.
        // We can reasonably assume no item can stay locked for more than
        // three hours, so if we find one in the tail which is that old,
        // free it anyway.
        item = lru.tryTailRepair(50, current_time);
        if (item != null) {
            // remove from hash
            assoc.delete(item.getKey());

            return item;
        }

        item = Item.createItem(totalLength, slabManager, useCas);
        return item;
    }

    /**
     * Get with expiriation logic. wrapper around assoc_find which does the lazy
     * expiration logic
     */
    public Item get(Region key)