Skip to content

Commit 0f5c5ea

Browse files
committed
DM-10370: forgot to commit ObjectSizeEngineWrapper.java
1 parent c31e780 commit 0f5c5ea

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
3+
*/
4+
5+
package edu.caltech.ipac.firefly.server.cache;
6+
7+
8+
import net.sf.ehcache.pool.Size;
9+
import net.sf.ehcache.pool.SizeOfEngine;
10+
import net.sf.ehcache.pool.impl.DefaultSizeOfEngine;
11+
12+
/**
13+
* @author Trey Roby
14+
*/
15+
public class ObjectSizeEngineWrapper extends DefaultSizeOfEngine {
16+
17+
public ObjectSizeEngineWrapper() {
18+
super(1000, false);
19+
}
20+
public ObjectSizeEngineWrapper(int maxDepth, boolean abortWhenMaxDepthExceeded) {
21+
super(maxDepth, abortWhenMaxDepthExceeded);
22+
}
23+
24+
public ObjectSizeEngineWrapper(int maxDepth, boolean abortWhenMaxDepthExceeded, boolean silent) {
25+
super(maxDepth, abortWhenMaxDepthExceeded, silent);
26+
}
27+
28+
@Override
29+
public SizeOfEngine copyWith(int maxDepth, boolean abortWhenMaxDepthExceeded) {
30+
// return super.copyWith(maxDepth, abortWhenMaxDepthExceeded);
31+
return new ObjectSizeEngineWrapper(maxDepth, abortWhenMaxDepthExceeded);
32+
}
33+
34+
@Override
35+
public Size sizeOf(Object key, Object value, Object container) {
36+
return (value instanceof BluffSize) ?
37+
new Size(((BluffSize)value).getSize(), true) :
38+
super.sizeOf(key,value,container);
39+
}
40+
41+
static public class BluffSize {
42+
private long size;
43+
public BluffSize(long size) {this.size= size;}
44+
public long getSize() { return size; }
45+
}
46+
}
47+

0 commit comments

Comments
 (0)