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

com.maxifier.mxcache.impl.caches.def.ObjectInlineCacheImpl Maven / Gradle / Ivy

/*
 * Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
 */
package com.maxifier.mxcache.impl.caches.def;

import com.maxifier.mxcache.caches.ObjectCalculatable;
import com.maxifier.mxcache.impl.MutableStatistics;
import com.maxifier.mxcache.impl.caches.abs.AbstractObjectCache;

/**
 * @author Alexander Kochurov ([email protected])
 */
public class ObjectInlineCacheImpl extends AbstractObjectCache {
    private volatile Object value = UNDEFINED;

    public ObjectInlineCacheImpl(Object owner, ObjectCalculatable calculable, MutableStatistics statistics) {
        super(owner, calculable, statistics);
    }

    @Override
    public Object load() {
        return value;
    }

    @Override
    public void save(T v) {
        value = v;
    }

    @Override
    public void clear() {
        value = UNDEFINED;
    }

    @Override
    public int size() {
        return value == UNDEFINED ? 0 : 1;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy