/** * Sets the current size of the buffer. * * @param currentSize * Size in bytes. */ public void setCurrentSize(long currentSize) { this.currentSize.set(currentSize); notifyEvictionIfNeeded(); }
/** * {@inheritDoc} * <p> * This method is thread safe. * <p> * Using this method does not provide any check for the supplied new maximum size. Thus, it is * responsibility of the user to assure that the given value is correct. */ @Override public void setMaxSize(long maxSize) { this.maxSize.set(maxSize); notifyEvictionIfNeeded(); }
/** * {@inheritDoc} * <p> * This method is thread safe. */ @Override public void setEvictionOccupancyPercentage(float evictionOccupancyPercentage) { this.evictionOccupancyPercentage.set(Float.floatToIntBits(evictionOccupancyPercentage)); notifyEvictionIfNeeded(); }
/** * Adds size value to the current size. * <p> * This method is thread safe. * * @param size * Size in bytes. * @param areObjects * Defines if the size that is added to the current size relates to the objects in * buffer. True means size is related to objects in buffer, false means that the size * relates to the indexing tree. */ void addToCurrentSize(long size, boolean areObjects) { currentSize.addAndGet(size); notifyEvictionIfNeeded(); if (areObjects) { dataAddedInBytes.addAndGet(size); } }