com.maxifier.mxcache.storage.Storage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mxcache-runtime Show documentation
Show all versions of mxcache-runtime Show documentation
Constains all classes necessary for launching a MxCache-instrumentated application
/*
* Copyright (c) 2008-2014 Maxifier Ltd. All Rights Reserved.
*/
package com.maxifier.mxcache.storage;
import gnu.trove.strategy.HashingStrategy;
import java.io.Serializable;
/**
* @author Alexander Kochurov ([email protected])
*/
public interface Storage {
HashingStrategy DEFAULT_HASHING_STRATEGY = new HashingStrategy() {
@Override
public int computeHashCode(Object object) {
return object == null ? 0 : object.hashCode();
}
@Override
public boolean equals(Object o1, Object o2) {
return o1 == null ? o2 == null : o1.equals(o2);
}
};
/** This object is returned by reference-value storages if no value is set for given key */
Object UNDEFINED = new Serializable() {
private static final long serialVersionUID = 0x1000L;
@Override
public String toString() {
return "";
}
@Override
public int hashCode() {
// large prime number
return 0x13D4FD;
}
private Object readResolve() {
return UNDEFINED;
}
};
void clear();
int size();
}