Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Membase | Memcached Server 1.0.3

Can only store strings?

3 replies [Last post]
  • Login or register to post comments
Fri, 04/23/2010 - 01:05
terry_brown
Offline
Joined: 04/20/2010
Groups: None

another silly question as I get my head around this - apologies.

Assuming the following against a working cache:
[CODE]MembaseClient client = new MembaseClient();
client.Store(StoreMode.Set, "Test1", new { Message = "Hello World" }); // no
client.Store(StoreMode.Set, "Test2", "Hello world"); // yes
client.Store(StoreMode.Set, user.UserId.ToString(), user); // no
[/CODE]

only the second line works - I don't seem able to Store anything other than strings?

I've looked against the running membase console for that bucket, and it appears that there is no activity against line 1, line 2 generates activity (and adds it to the cache), line 3 does nothing.

I seem to remember reading something about text and binary mode, but can't find a setting for it anywhere.

Any help gratefully appreciated.

Kind Regards,
Terry

Top
Fri, 04/23/2010 - 06:27
Attila Kisko
Offline
Joined: 04/22/2010
Groups: None

To store objects in the cache they must be serializable. (If you enable logging I think this will show up in the log as well.)

you have 3 options
1. add the [Serializable] attribute to your data classes
2. implement ISerializable
3. If none of the above are possible (for example 3rd party sealed classes, etc.), you can create a custom serializer, by implementing the ITranscoder interface (or just inherit from the DefaultTranscoder, which is a good starting point to check out how is that working.)

Top
Fri, 04/23/2010 - 08:07
terry_brown
Offline
Joined: 04/20/2010
Groups: None

Superstar, cheers Attila.

[Serializable] did the trick - I'm now fully working and all is as expected!

Thanks,
Terry

Top
Fri, 04/23/2010 - 08:15
ingenthr
Offline
Joined: 03/16/2010
Groups:

Thanks Attila!

Sorry for the forum troubles. We'll look into that as well.

Top
  • 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