{"id":17273262,"url":"https://github.com/alexfernandez/nodecached","last_synced_at":"2025-02-25T01:31:49.286Z","repository":{"id":11626976,"uuid":"14126881","full_name":"alexfernandez/nodecached","owner":"alexfernandez","description":"Memcached server written in node.js","archived":false,"fork":false,"pushed_at":"2020-05-02T18:01:20.000Z","size":166,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-19T09:38:48.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexfernandez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-04T23:32:06.000Z","updated_at":"2024-07-31T14:37:21.000Z","dependencies_parsed_at":"2022-08-31T22:52:10.188Z","dependency_job_id":null,"html_url":"https://github.com/alexfernandez/nodecached","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfernandez%2Fnodecached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfernandez%2Fnodecached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfernandez%2Fnodecached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfernandez%2Fnodecached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexfernandez","download_url":"https://codeload.github.com/alexfernandez/nodecached/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240586573,"owners_count":19824921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T08:50:48.744Z","updated_at":"2025-02-25T01:31:48.982Z","avatar_url":"https://github.com/alexfernandez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://secure.travis-ci.org/alexfernandez/nodecached.png)](http://travis-ci.org/alexfernandez/nodecached)\n\n# nodecached\n\nnodecached is a memcached-compatible server and client written in node.js.\n\nThe client is a full-blown driver for any remote memcached servers.\n\nThe server is useful if you want a simple memcached server that integrates with your existing node.js infrastructure;\notherwise just use [the original memcached](http://memcached.org/) which is a very lightweight\nprogram and blazing fast.\n\nnodecached can also be used as an in-memory cache.\n\n## Installation\n\nInstalling the package is very simple. Just install globally using npm:\n\n    # npm install -g nodecached\n\nOn Ubuntu or Mac OS X systems, use `sudo`:\n\n    $ sudo npm install -g nodecached\n\n### Compatibility\n\nVersions 1 and later should be used at least with Node.js v8 or later:\n\n* Node.js v8 or later: ^1.0.0\n* Node.js v6 or earlier: ^0.2.0.\n\n## nodecached Server\n\nnodecached is primarily a server compatible with memcached.\n\n### Usage\n\nStart from the command line:\n\n    $ nodecached\n\n### Options\n\nOptions are designed to be compatible with the original memcached, whenever possible.\n\n* `-p port`: Start server on the given port.\n* `-v`: Show notice messages.\n* `-vv`: Show info messages.\n* `-vvv`: Show debug messages.\n\n### Advanced Options\n\nThese options are specific for nodecached.\n\n* `--delay`: Enable Nagle's algorithm. Useful for measuring the cost of not setting the option `nodelay`.\n* `--fast`: Do not parse commands and return an error on all queries. Useful for measuring socket performance.\n\n### Server Commands\n\nnodecached accepts the following commands, based on [the original commands](https://github.com/memcached/memcached/blob/master/doc/protocol.txt):\n\n#### Storage\n\nThere are a few storage commands that start with a header like this:\n\n`\u003ccommand\u003e \u003ckey\u003e \u003cflags\u003e \u003cexptime\u003e \u003cbytes\u003e\\r\\n`\n\n* `\u003ccommand\u003e` is `set`, `add`, `replace`, `append` or `prepend`.\n\n* `\u003ckey\u003e` is a string that will identify the element.\n\n* `\u003cflags\u003e` is a 32-bit integer to store with the value.\n\n* `\u003cexptime\u003e` is expiration time in seconds.\n\n* `\u003cbytes\u003e` is the length of the data in bytes.\n\nAfterwards the server will expect the data block:\n\n`\u003cdata\u003e\\r\\n`\n\nwith a length of `\u003cbytes\u003e`.\n\nThe server will respond with:\n\n* `STORED\\r\\n` to indicate success.\n\n* `NOT_STORED\\r\\n` to indicate failure.\n\n#### Retrieval\n\nThe command `get` has the following syntax:\n\n`get \u003ckey\u003e\\r\\n`\n\nwhere `\u003ckey\u003e` is a string that identifies an element.\n\n#### Deletion\n\nThe command to delete a record is:\n\n`delete \u003ckey\u003e\\r\\n`\n\nwhere the `\u003ckey\u003e` identifies the record.\nThe server will respond with:\n\n* `DELETED` to indicate that the record has been deleted.\n\n* `NOT_DELETED` if the value is not found.\n\n#### Statistics\n\nThe following command will retrieve a set of stats.\n\n`stats\\r\\n`\n\nThe stats include `pid`, `total_items` and a few others.\n\n#### Version\n\nThis simple command retrieves the version of nodecached.\n\n`version\\r\\n`\n\nThe response will be something like this:\n\n`VERSION \u003cstring\u003e`\n\nThe version `\u003cstring\u003e` will always start with `nodecached-`.\n\n### Caveats\n\nnodecached may strive to be compatible with memcached, but it is not equivalent.\nTo start with, it will probably consume more memory and be slower -- in my tests about three times as slow.\n\nOn the other hand, the absolute difference amounts to about 20 µs per request --\nthat is 20 millionths of a second.\nTypical network latencies are about 10 times bigger than that.\nSo the difference might not be an issue to you.\n\nIn any case, this is a preliminary version which is not even protocol-complete yet.\nPlease use with care.\n\nMissing commands are: `gets`, `cas`, `slabs [command]`, `stats [option]`.\nGeneral purpose statistics are by no means complete.\nThe option `noreply` is not supported yet.\nUDP and binary protocols are out of scope at the moment.\n\n## Memcached Client\n\nnodecached can be used as a client to a remote system.\nIt has been designed to be a drop-in replacement for\n[node-memcached](https://github.com/3rd-Eden/node-memcached).\n\n### Usage\n\nYou can integrate nodecached into your code as a client.\nIt is mostly compatible with node-memcached, so it should be a drop-in replacement.\nJust create a client with a location and options, and use it:\n\n    var Client = require('nodecached').Client;\n    var client = new Client('localhost:11311', {\n\t\ttimeout: 3000,\n\t});\n\n### API\n\nThe API has the following functions.\n\n#### Client(location, options, callback)\n\nCreate the client.\n* location: a string with the location `host:port`.\nCan also be an array of locations, or an object with {location: weight}.\nNote: weights are ignored right now.\n\n#### client.get(key, callback)\n\nRetrieve an object from the server by key, and send to the callback.\n* key: a string with the memcached key.\n* callback: function(error, value) to call with the retrieved value.\n\n#### client.set(key, value, lifetime, callback)\n\nStore an object in the server by key.\n* key: a string with the memcached key.\n* value: the object to store.\n* lifetime: max seconds to store.\n* callback: function(error, result) to call, true if stored.\n\n#### client.delete(key, callback)\n\nDelete an object from the server by key.\n* key: a string with the memcached key.\n* callback: function(error, result) to call, true if deleted, false otherwise.\n\n#### client.incr(key, value, callback)\n\nIncrement a numeric value from the server by key.\n* key: a string with the memcached key.\n* value: the value to add to the original.\n* callback: function(error, result) to call with the incremented value,\nor false if not found.\n\n#### client.decr(key, value, callback)\n\nDecrement a numeric value from the server by key.\n* key: a string with the memcached key.\n* value: the value to substract from the original.\n* callback: function(error, result) to call with the decremented value,\nor false if not found.\n\n### Options\n\nThe client accepts some options compatible with node-memcached.\n\n* `timeout`: ms to wait for a response from the server.\n\n## In-memory Cache\n\nnodecached can also work as an in-memory cache, again compatible with\n[node-memcached](https://github.com/3rd-Eden/node-memcached).\n\n## References\n\n* [protocol.txt](https://github.com/memcached/memcached/blob/master/doc/protocol.txt)\n* [node-memcached](https://github.com/3rd-Eden/node-memcached)\n* [jscached](https://github.com/monsur/jscache)\n* [memcached configuration](https://code.google.com/p/memcached/wiki/NewConfiguringServer)\n\n\n## License\n\nDistributed under the MIT license. See the file LICENSE for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexfernandez%2Fnodecached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexfernandez%2Fnodecached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexfernandez%2Fnodecached/lists"}