package ca.szc.keratin.bot.util;

public abstract class CachedValue<T>
{
    private long lastUpdateMillis;

    private long expiryMillis = expiryMillis();

    private T cachedValue = null;

    public T getValue()
    {
        if ( cachedValue == null || System.currentTimeMillis() >= lastUpdateMillis + expiryMillis )
        {
            cachedValue = updateValue();
            lastUpdateMillis = System.currentTimeMillis();
        }

        return cachedValue;
    }

    protected void setExpiryMillis( long expiryMillis )
    {
        this.expiryMillis = expiryMillis;
    }

    protected abstract T updateValue();

    protected abstract long expiryMillis();
}
@@ -197,16 +197,29 @@
  public 
+synchronized 
 T getVal

Make CachedValue thread safe