Siddharth
Siddharth

Reputation: 9574

How fast is memcached set operation?

I need to design a cache for storing objects coming in from multiple clients. These clients can all come in parallel. These objects need to stored on memcached, and retrieved later for use.

String newKey ;
private synchronized String setData(Data newData) {
    do {
        newKey = createRandomKey() ;
    } while (memcacheClient.get(newKey) != null) ;
    memcacheClient.set(newKey, 10000, newData) ;
}

My question is, will this method become a bottleneck for parallel client access ?

OR

Should I create a shared List and a Thread. The thread will do the setData, asynchronously ?

Upvotes: 1

Views: 187

Answers (1)

Shen Li
Shen Li

Reputation: 411

The delay of the loop heavily depends on how random createRondomKey can achieve. Do you have to use random keys? Is it possible to come up with some semantic naming schemes (e.g., userid/category/blabla)? That will also save you the efforts to remember the random keys.

Upvotes: 1

Related Questions