当前位置: 首页>>代码示例>>Java>>正文


Java CouchbaseClient.set方法代码示例

本文整理汇总了Java中com.couchbase.client.CouchbaseClient.set方法的典型用法代码示例。如果您正苦于以下问题:Java CouchbaseClient.set方法的具体用法?Java CouchbaseClient.set怎么用?Java CouchbaseClient.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.couchbase.client.CouchbaseClient的用法示例。


在下文中一共展示了CouchbaseClient.set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setValue

import com.couchbase.client.CouchbaseClient; //导入方法依赖的package包/类
public void setValue(final Object key, final Object value) {
	try {
		CouchbaseClient client = getClient();

		if (value instanceof CouchbaseDocument) {
			client.set(key.toString(), ((CouchbaseDocument) value).toString());
		} else {
			client.set(key.toString(), value);
		}
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:14,代码来源:XSPCouchbaseConnection.java

示例2: copyWorkflowNoSQL

import com.couchbase.client.CouchbaseClient; //导入方法依赖的package包/类
private static int copyWorkflowNoSQL(ViewResponse result, int limit, CouchbaseClient client, int currentSize, CouchbaseClient hiwayClient) {
	Gson gson = new Gson();
	WfRunDoc newRun = null;
	WfRunDoc run = null;

	System.out.println("copy NoSQL anzwahl wf:" + currentSize + " resultSize:" + result.size());

	int i = 0;
	// Iterate over the found wf documents
	for (ViewRow row : result) {
		i++;
		if (currentSize + i >= limit + 1) {
			System.out.println("Break and raus: all: " + currentSize + " | i: " + i + " limit: " + limit);
			return i;
		}
		run = gson.fromJson((String) row.getDocument(), WfRunDoc.class);

		if (run.getRunId() != null) {
			String newName = run.getRunId().substring(0, 36) + "_" + Calendar.getInstance().getTimeInMillis();
			System.out.println("Run: " + run.getName() + " , I: " + i + " | " + newName);

			newRun = new WfRunDoc();
			newRun.setRunId(newName);
			newRun.setName(run.getName());
			newRun.setWfTime(run.getWfTime());
			newRun.setHiwayEvent(run.getHiwayEvent());
			newRun.setTaskIDs(run.getTaskIDs());

			client.set(newName, gson.toJson(newRun));

			View view = hiwayClient.getView("Workflow", "WfRunInvocs");
			Query query = new Query();
			query.setIncludeDocs(true).setKey(run.getRunId());

			// Query the Cluster
			ViewResponse newResult = hiwayClient.query(view, query);

			InvocDoc newInvoc = null;
			InvocDoc oldInvoc = null;

			for (ViewRow invocDoc : newResult) {
				oldInvoc = gson.fromJson((String) invocDoc.getDocument(), InvocDoc.class);

				newInvoc = new InvocDoc();
				newInvoc.setHostname(oldInvoc.getHostname());
				newInvoc.setLang(oldInvoc.getLang());
				newInvoc.setRealTime(oldInvoc.getRealTime());
				newInvoc.setRealTimeIn(oldInvoc.getRealTimeIn());
				newInvoc.setRealTimeOut(oldInvoc.getRealTimeOut());
				newInvoc.setRunId(newName);
				newInvoc.setScheduleTime(oldInvoc.getScheduleTime());
				newInvoc.setStandardError(oldInvoc.getStandardError());
				newInvoc.setStandardOut(oldInvoc.getStandardOut());
				newInvoc.setTaskId(oldInvoc.getTaskId());
				newInvoc.setTaskname(oldInvoc.getTaskname());
				newInvoc.setTimestamp(Calendar.getInstance().getTimeInMillis());
				newInvoc.setInvocId(oldInvoc.getInvocId());
				newInvoc.setFiles(oldInvoc.getFiles());
				newInvoc.setInput(oldInvoc.getInput());
				newInvoc.setOutput(oldInvoc.getOutput());
				newInvoc.setUserevents(oldInvoc.getUserevents());

				String invocID = newName + "_" + newInvoc.getInvocId();

				System.out.println("save invoc..." + invocID);
				client.set(invocID, gson.toJson(newInvoc));
			}
		}

	}
	return i;

}
 
开发者ID:marcbux,项目名称:Hi-WAY,代码行数:74,代码来源:Reader.java

示例3: save

import com.couchbase.client.CouchbaseClient; //导入方法依赖的package包/类
public boolean save() throws IOException {
	CouchbaseClient client = getClient();
	client.set(key_, toString());
	return true;
}
 
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:6,代码来源:CouchbaseDocument.java

示例4: saveSerializedView

import com.couchbase.client.CouchbaseClient; //导入方法依赖的package包/类
@Override
public SerializedView saveSerializedView(FacesContext facesContext) {
	print("--------------------------");
	print("running saveSerializedView");
	
	try {

		UIViewRootEx view = (UIViewRootEx)facesContext.getViewRoot();
		String key = view.getUniqueViewId();
		
		Database database = ExtLibUtil.getCurrentDatabase();
		key = database.getReplicaID() + key;
		print("storage key is " + key);
		
		// Connect to our Couchbase server
		CouchbaseClient client = getClient();
		
		// Fetch or create a holder object and store the view
		BasicStateManagerImpl.ViewHolder holder = (BasicStateManagerImpl.ViewHolder)client.get(key);
		if(holder == null) {
			Class<BasicStateManagerImpl.ViewHolder> holderClass = BasicStateManagerImpl.ViewHolder.class;
			Constructor<?> cons = holderClass.getDeclaredConstructors()[1];
			cons.setAccessible(true);
			holder = (BasicStateManagerImpl.ViewHolder)cons.newInstance(1);
		}
		holder.add(facesContext, view);
		
		// Do our Externalization here to avoid trouble with the CouchbaseClient ClassLoader not finding the holder class later
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		ObjectOutputStream oos;
		if(gzip_) {
			oos = new ObjectOutputStream(new GZIPOutputStream(bos));
		} else {
			oos = new ObjectOutputStream(bos);
		}
		holder.writeExternal(oos);
		oos.flush();
		bos.flush();
		
		byte[] bytes = bos.toByteArray();
		
		// Set an expiration value
		XSPContext context = ExtLibUtil.getXspContext();
		String timeout = context.getProperty("xsp.session.timeout");
		int expiration;
		if(StringUtil.isEmpty(timeout)) {
			expiration = 30 * 60;
		} else {
			expiration = Integer.parseInt(timeout) * 60;
		}
		
		
		client.set(key, expiration, bytes);
		print("added view to holder");
	} catch(Exception e) { throw new RuntimeException(e); }

	print("--------------------------");
		
	return null;
}
 
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:61,代码来源:CouchbaseStateManager.java

示例5: saveSerializedView

import com.couchbase.client.CouchbaseClient; //导入方法依赖的package包/类
@Override
public SerializedView saveSerializedView(FacesContext facesContext) {
	print("--------------------------");
	print("running saveSerializedView");

	try {

		UIViewRootEx view = (UIViewRootEx) facesContext.getViewRoot();
		String key = view.getUniqueViewId();

		Database database = (Database) getVariableValue("database");
		key = database.getReplicaID() + key;
		print("storage key is " + key);

		// Connect to our Couchbase server
		CouchbaseClient client = getClient();

		// Fetch or create a holder object and store the view
		BasicStateManagerImpl.ViewHolder holder = (BasicStateManagerImpl.ViewHolder) client.get(key);
		if (holder == null) {
			Class<BasicStateManagerImpl.ViewHolder> holderClass = BasicStateManagerImpl.ViewHolder.class;
			Constructor<?> cons = holderClass.getDeclaredConstructors()[1];
			cons.setAccessible(true);
			holder = (BasicStateManagerImpl.ViewHolder) cons.newInstance(1);
		}
		holder.add(facesContext, view);

		// Do our Externalization here to avoid trouble with the
		// CouchbaseClient ClassLoader not finding the holder class later
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		ObjectOutputStream oos;
		if (gzip_) {
			oos = new ObjectOutputStream(new GZIPOutputStream(bos));
		} else {
			oos = new ObjectOutputStream(bos);
		}
		holder.writeExternal(oos);
		oos.flush();
		bos.flush();

		byte[] bytes = bos.toByteArray();

		// Set an expiration value
		XSPContext context = ExtLibUtil.getXspContext();
		String timeout = context.getProperty("xsp.session.timeout");
		int expiration;
		if (StringUtil.isEmpty(timeout)) {
			expiration = 30 * 60;
		} else {
			expiration = Integer.parseInt(timeout) * 60;
		}

		client.set(key, expiration, bytes);
		print("added view to holder");
	} catch (Exception e) {
		throw new RuntimeException(e);
	}

	print("--------------------------");

	return null;
}
 
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:63,代码来源:CouchbaseStateManager.java


注:本文中的com.couchbase.client.CouchbaseClient.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。