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

com.alogic.cache.xscript.CacheHashSize Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.alogic.cache.xscript;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.alogic.cache.CacheObject;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;

/**
 * 查询cache中hash的个数
 * @author yyduan
 * @since 1.6.11.29
 */
public class CacheHashSize extends CacheObjectOperation{
	
	/**
	 * 分组
	 */
	protected String $group = CacheObject.DEFAULT_GROUP;
	
	/**
	 * 输出变量id
	 */
	protected String $id;
	
	public CacheHashSize(String tag, Logiclet p) {
		super(tag, p);
	}
	
	@Override
	public void configure(Properties p){
		super.configure(p);
		
		$id = PropertiesConstants.getRaw(p, "id", "$" + getXmlTag());
		$group = PropertiesConstants.getRaw(p, "group", $group);
	}

	@Override
	protected void onExecute(CacheObject cache, Map root,
			Map current, LogicletContext ctx,
			ExecuteWatcher watcher) {
		String id = PropertiesConstants.transform(ctx, $id, "$" + getXmlTag());
		
		if (StringUtils.isNotEmpty(id)){
			ctx.SetValue(
				id, 
				String.valueOf(
					cache.hLen(PropertiesConstants.transform(ctx, $group, CacheObject.DEFAULT_GROUP))
				)
			);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy