Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Storing arrays in a document

1 reply [Last post]
  • Login or register to post comments
Tue, 05/01/2012 - 08:44
shirish87
Offline
Joined: 05/01/2012
Groups: None

Hi,

I'm relatively new to the NoSQL universe, and I'm looking for some guidance with the Memcached Java client and Couchbase.

Referring to Rags' presentation on Slideshare, if my model consists of Player, Plant and Player_Plant List, how do I go about storing the Player_Plant list in a distributed app scenario. If I have an in-memory Java object for Player1_Plant on one app server instance and I use client.set() to update the value, I could potentially be blindly overwritting changes done by another app instance. Do we use CAS operations to handle situations like these?

CASValue<Object> cas = client.gets("Player1_Plant");
CASResponse response = client.cas( "Player1_Plant" ,  cas.getCas(), mapper.writeValueAsString(player1_plantList));

...and then check the response?

And in what situations or use-cases are client.append() and client.prepend() used? Can they work with JSON?

Thanks.

 

Top
  • Login or register to post comments
Thu, 05/31/2012 - 08:10
ingenthr
Offline
Joined: 03/16/2010
Groups:

Yes, CAS operations are the best way to ensure you have consistent updates to that document.

It is possible to use append/prepend, but that will not work with JSON documents because of the format. Some people use special characters, like "|" to delimit the field, rather than JSON and CAS.

With 2.0, you'll be able to do more with JSON documents, so that's generally recommended.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker