开发者

How can I access memcached with Javascript?

开发者 https://www.devze.com 2023-02-09 05:00 出处:网络
Let\'s say I have a working memcached deamon on a server. Let\'s say that this server is able to handle server side Javascript (APE in my case).

Let's say I have a working memcached deamon on a server. Let's say that this server is able to handle server side Javascript (APE in my case).

It should be easy to access memcached with some Javascript right on the server (I mean, in my mind...).

But I've to admit I'm running out of idea...

"Help plz" ? :)

Thanks

EDIT :

This is working :

Ape.registerCmd("CMD", true, function(params, infos) {
Ape.log("cmd called");

var socket = new Ape.sockClient("11211", "127.0.0.1", {flushlf: true});

socket.onConnect = function() {
    Ape.log("Connected to Memcached");
    Ape.log("Issued 'stats' commande to Memcached...");
   this.write("stats\n");
    this.onRead = function(data) {
        Ape.log("Data from memcached : " + data);
    }
}
//data = ...
infos.sendResponse('return', {'data'开发者_开发问答:data});
});


You talk to memcached over a socket, so if whatever server runs your JavaScript has a socket API you can write a memcached client for it.

If you can write javascript modules in C you can also do it, even if you don't have socket support in JavaScript.


It seems that there already exist memcache clients for JavaScript. You could try jsmemcached for example.


silkjs has a memcache mechanism built in it.

Here is the documentation: http://silkjs.org/documentation/Memcached

0

精彩评论

暂无评论...
验证码 换一张
取 消