// Path: src/main/java/com/tellerulam/logic4mqtt/TopicCache.java
// static public class TopicValue
// {
// 	private TopicValue(Object value, Date ts,Object fullValue)
// 	{
// 		this.value=value;
// 		this.ts=ts;
// 		this.lastRefresh=ts;
// 		this.fullValue=fullValue;
// 	}
// 	public final Object value,fullValue;
// 	public final Date ts;
// 	public Date lastRefresh;
// 	void markAsRefreshed()
// 	{
// 		lastRefresh=new Date();
// 	}
// }


import java.util.*;
import com.tellerulam.logic4mqtt.*;
import com.tellerulam.logic4mqtt.TopicCache.TopicValue;
	}

	public void queueStore(String timespec,String topic,Map<String,Object> value)
	{
		internalQueueSet(timespec,topic,ScriptEngineTools.encodeAsJSON(value),true);
	}

	/**
	 * Clears possibly queued value sets for the given topic
	 *
	 * @param topic the topic to clear the queue for
	 * @return number of removed queued set
	 */
	public int clearQueue(String topic)
	{
		return LogicTimer.remTimer("_SET_"+TopicCache.convertSetTopic(topic));
	}

	/**
	 *
	 * Get a cached last value of a topic, or null if the topic or the specified
	 * generation is not known.
	 *
	 * @param topic
	 * @param generation (0 = current, 1 = previous, ...)
	 * @return the value, or null
	 */
	public Object getValue(String topic,int generation)
	{
		topic=TopicCache.convertStatusTopic(topic);
// Path: src/main/java/com/tellerulam/logic4mqtt/TopicCache.java
// static public class TopicValue
// {
// 	private TopicValue(Object value, Date ts,Object fullValue)
// 	{
// 		this.value=value;
// 		this.ts=ts;
// 		this.lastRefresh=ts;
// 		this.fullValue=fullValue;
// 	}
// 	public final Object value,fullValue;
// 	public final Date ts;
// 	public Date lastRefresh;
// 	void markAsRefreshed()
// 	{
// 		lastRefresh=new Date();
// 	}
// }


// Path: src/main/java/com/tellerulam/logic4mqtt/api/Events.java
import java.util.*;
import com.tellerulam.logic4mqtt.*;
import com.tellerulam.logic4mqtt.TopicCache.TopicValue;

	}

	public void queueStore(String timespec,String topic,Map<String,Object> value)
	{
		internalQueueSet(timespec,topic,ScriptEngineTools.encodeAsJSON(value),true);
	}

	/**
	 * Clears possibly queued value sets for the given topic
	 *
	 * @param topic the topic to clear the queue for
	 * @return number of removed queued set
	 */
	public int clearQueue(String topic)
	{
		return LogicTimer.remTimer("_SET_"+TopicCache.convertSetTopic(topic));
	}

	/**
	 *
	 * Get a cached last value of a topic, or null if the topic or the specified
	 * generation is not known.
	 *
	 * @param topic
	 * @param generation (0 = current, 1 = previous, ...)
	 * @return the value, or null
	 */
	public Object getValue(String topic,int generation)
	{
		topic=TopicCache.convertStatusTopic(topic);
		TopicValue tv=TopicCache.getTopicValue(topic, generation);