Using Couchbase with memcached protocol from Java - java

Can someone point me to example of Java code that can work both with Memcached server and Couchbase server. If i understand correctly one can use spymemcached for communicating with both server. Does that mean i can use same code to connect(obviously using different url) get and put values to them or there are some differences?

Any particular reason to use the memcached protocol directly?
The best practice when working with Couchbase is to use the Client SDK (many languages are supported as you can see here http://www.couchbase.com/develop , including Java) ?
The reason why it is better to use the SDK (and for the same reason you have to use Moxi) is because to be able to support the clustering from your application.
You client SDK will direct the operations to the correct cluster nodes, but also the cluster map will automatically be updated when you add new nodes (or when nodes are failing).
The Java SDK tutorial will guide you through the different steps of developing an application using Couchbase:
- http://www.couchbase.com/docs/couchbase-sdk-java-1.1/tutorial.html
So, can you use the Java client SDK?

According to the couchbase documentation it support textual memcached protocol. So you can use any of the available java memcached client and reuse the same code used for memcached. Couchbase supports memcached protocol only through moxi.

Related

Neo4j rest client in Java

I want to access Neo4j db concurrently through a rest client in java.
I have already found two clients neo4j-rest-graphdb 2.0.1 and neo4j-jdbc 2.3.2 .
Since first one is no longer maintained I'm afraid to go with it.
Can someone please tell me what is the best java rest client for Neo4j which support concurrent access?
I think what you're looking for is Neo4j-OGM
Neo4j OGM is a fast object-graph mapping library for Neo4j, optimised for server-based installations and utilising Cypher via the transactional HTTP endpoint.
It's created and maintained by Neo4j team.
Concurrency is managed by Neo4j itself, you can use any client without worrying for concurrency problem.

CouchBase Client vs Spymemcache, Client Usage

I am to use CouchBase as my caching layer. My caches are serialized objects and not(always) Document type or JSON values. The couchbase client(Couchbase-Java-Client-1.4.3) also uses Spymemcache jars which is the client of memcached server.
My questions are,
Should I use only Couchbas Client to cache my objects into couchbase server?
What if I use default Spymemcache client to cache ? if I use, what could be pros and conse over the using couchbase client? Can the Spymemcache client handle server nodes and node failures itself?
You should not use Spymemcached with Couchbase. You can, but I would recommend against it. First off, CouchbaseClient uses the Spymemcached jar because both Memcached and Couchbase use the memcached binary protocol for key-value operations. When we initially started writing a Java Client for Couchbase it didn't make sense to re-implement something that was already written so we used Spymemcached because it performs very well. You can think of Spymemcached as doing all of the basic stuff like sending messages and Couchbase Client as adding all of the nice functionality that makes it really easy to use Couchbase.
What if I use default Spymemcache client to cache ?
Everything goes through the cache regardless of what client you use so there is not point in using two different clients.
What could be pros and cons over the using couchbase client?
If you don't use CouchbaseClient you will be using something a lot more primitive. Think about it this way. Couchbase has spent about 3 years adding features to CouchbaseClient that make it really easy to use the Couchbase. CouchbaseClient will deal with topology changes and also adds operations that Spymemcached does not have.
Can the Spymemcache client handle server nodes and node failures itself?
No, but if you send traffic through Moxi then you will be able to deal with node failures.
I wouldn't even both with Spymemcached if your using Couchbase.

Can Hazelcast be used as a cache for *perl* web apps?

I am looking at quickly implementing a hazelcast in-memory cache for a web application.
The web application is written in perl...
...so is there a way to access a hazelcast Map via perl?
Or, in worst case, must I write a thin hazelcast client in java, and call that from perl?
Thanks
Steve
I'd suggest looking at Cache::Memcached as this post to the hazelnut google groups seems to imply that someone else has already done this using this module.
For other solutions, you could continue searching on cpan for Memcache. Or for a non distributed solution, can just go with the core library Memoize.
If there a memcached client for Perl? If so you can use the memcached protocol to connect to Hazelcast.
Chris
Hazelcast could be used through its REST Api so you need a JVM with Java library to support this feature.

Can we Test Object's presence in Oracle Coherence?

I have a requirement where i need to create a third party application which will test any object's presence in Oracle Coherence.
Scenario: Our main application uses Oracle Coherence to store some data, now i have to create a separate application (which will be running on a different server - out of the coherence cluster node). This particular application will detect whether some particular object is present in the coherence or not. We have no plans to run coherence on this machine too.
Can any third party application (which is not part of the coherence cluster) connect to coherence and fetch data? If yes then how? can i get some pointers to do the same?
There are multiple ways you can do it.
1) Use Coherence Extend - This allows any application to interact with Coherence without being part of Coherence Cluster.
Refer to http://docs.oracle.com/cd/E14526_01/coh.350/e14509/configextend.htm
This option is supported only if the third part application is in Java, .Net or C++
http://coherence.oracle.com/display/COH35UG/Coherence+Extend#CoherenceExtend-Typesofclients
2) Use REST API - The newer/latest versions of Coherence exposes cache data management using REST API's. Refer to http://docs.oracle.com/cd/E24290_01/coh.371/e22839/rest_intro.htm
This option does not have any restriction on client/third part technology as it is based on XML/JSON over HTTP.
Using REST you can check presence of cache key as below.
GET Operation
GET http://{host}:{port}/cacheName/key
Returns a single object from the cache based on a key. A 404 (Not Found) message is returned if the object with the specified key does not exist.
I created such a tool some time back using the C++ API.
https://github.com/actsasflinn/coherence-tool
I also wrapped the C++ API in a Ruby binding for scripting purposes.
https://github.com/actsasflinn/ruby-coherence
Either of these can run standalone outside of the cluster and rely on the TCP proxy method of communicating with a cluster.

Connect PHP Client to Java backend

I need to connect PHP client code to JAVA backend, where the actions are :
1. http request will be sent from PHP client.
2. It will interact with JAVA code on Model and will store data in Nosql using JAVA backend
I read about this php-java bridge
Which can be better PHP-JAVA bridge to use?
Take a look at Project Zero and Quercus. Both of those may be helpful. The php-java bridge that you linked to may prove most useful though as its built to work with the official PHP distribution.

Categories