private long safeSizeOf(Object key, ICacheable value) {
        long result = value.sizeOf();
        if (result < 0) {
            throw new IllegalStateException("Negative size: " + key + "=" + value);
        }
        return result;
    }