本文整理汇总了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);
}
}
示例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;
}
示例3: save
import com.couchbase.client.CouchbaseClient; //导入方法依赖的package包/类
public boolean save() throws IOException {
CouchbaseClient client = getClient();
client.set(key_, toString());
return true;
}
示例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;
}
示例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;
}