All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsimpledb.kv.caching.AbstractCachingConfig Maven / Gradle / Ivy


/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package org.jsimpledb.kv.caching;

import com.google.common.base.Preconditions;

/**
 * Support superclass for {@link CachingConfig} implementations.
 */
public abstract class AbstractCachingConfig implements CachingConfig {

    int maxRanges = DEFAULT_MAX_RANGES;
    long maxRangeBytes = DEFAULT_MAX_RANGE_BYTES;
    long maxTotalBytes = DEFAULT_MAX_TOTAL_BYTES;
    boolean readAhead = DEFAULT_READ_AHEAD;

    /**
     * Constructor.
     */
    protected AbstractCachingConfig() {
    }

    @Override
    public synchronized long getMaxRangeBytes() {
        return this.maxRangeBytes;
    }

    @Override
    public synchronized void setMaxRangeBytes(long maxRangeBytes) {
        Preconditions.checkArgument(maxRanges > 0, "maxRangeBytes <= 0");
        this.maxRangeBytes = maxRangeBytes;
    }

    @Override
    public synchronized long getMaxTotalBytes() {
        return this.maxTotalBytes;
    }

    @Override
    public synchronized void setMaxTotalBytes(long maxTotalBytes) {
        Preconditions.checkArgument(maxTotalBytes > 0, "maxTotalBytes <= 0");
        this.maxTotalBytes = maxTotalBytes;
    }

    @Override
    public synchronized int getMaxRanges() {
        return this.maxRanges;
    }

    @Override
    public synchronized void setMaxRanges(int maxRanges) {
        Preconditions.checkArgument(maxRanges > 0, "maxRanges <= 0");
        this.maxRanges = maxRanges;
    }

    @Override
    public synchronized boolean isReadAhead() {
        return this.readAhead;
    }

    @Override
    public synchronized void setReadAhead(boolean readAhead) {
        this.readAhead = readAhead;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy