memcing v1.0.0
Memcing
Memcing is an in-memory key-value caching application with RESTful API.
Installation
npm install memcingUsage
Interactive mode
npm startAdd an entry (add hello world) and see http://localhost:12080/entries/hello
Help
./memcing -help Options:
-i : Enable interactive mode.
-listen-http : Listen HTTP requests. Default; 0.0.0.0:12080
-load-file : Load a command file.
-cache-limit : Cache size limit in bytes. Default (128MB); 134217728
-entry-limit : Entry size limit in bytes. Default (1KB); 1024
-vacuum-delay : Delay in seconds for vacuum. Default; 30
-eviction : Enable eviction mode.
-debug : Enable debug mode.
-verbose : Set verbose message level. Default; 1
-help : Display help and exit.
stdin:
-cmd : Enable command mode for stdin.
-csv : Enable CSV mode for stdin.
-csv-delimiter : CSV delimiter (char or `tab`). Default; ,
-csv-field-key : Key field index on CSV. Default; 1
-csv-field-filter : Include fields on CSV. Default (all); null
Example; -csv-field-filter 1,2
Interactive mode commands:
get key
set key value [expire = 0]
add key value [expire = 0]
increment key [amount = 1]
decrement key [amount = 1]
delete key
drop
dump
stats
vacuum
exitExamples
Interactive Mode
./memcing -load-file ../test/cmds-lf.txt -i -listen-httpReads commands from cmds-lf.txt then switch to interactive mode and listen
ttp requests. The cached data will be available for REPL and RESTful API.
For RESTful API performance tests;
ab -n 10000 http://localhost:12080/entries/hello
ab -n 10000 -c 100 http://localhost:12080/entries/helloPostal Code Service Example
You can easily create a postal code service;
wget -qO zip-codes.zip http://download.geonames.org/export/zip/US.zip && \
unzip -p zip-codes.zip US.txt | \
cat | \
./memcing -listen-http -csv -csv-delimiter tab -csv-field-key 2 -csv-field-filter 1,3,4,5,6,10,11See http://localhost:12080/entries/78729
{
"key":"78729",
"val":"[\"US\",\"Austin\",\"Texas\",\"TX\",\"Williamson\",\"30.4521\",\"-97.7688\"]",
"ts":1401417873489,
"expTS":0
}If you want to include other countries see http://download.geonames.org/export/zip/
and change the part (US.zip and US.txt) of the command at above.
RESTful API
RESTful API is still under development. For the current implementations see Implementations
- Use
application/x-www-form-urlencodedfor request method. - Use
valquery parameter for value. - Use
expquery parameter for expiration.
PUT
/entries/{KEY}PUT method represent the set command.
Examples:
curl -X PUT -d "val=world" http://localhost:12080/entries/hello
curl -X PUT -d "val=world&exp=10" http://localhost:12080/entries/byePOST
/entries/{KEY}POST method represent the add command.
Examples:
curl -X POST -d "val=1" http://localhost:12080/entries/counterGET
/entries
/entries/{KEY}GET method represent the get command.
Examples:
curl http://localhost:12080/entries
curl http://localhost:12080/entries/helloDELETE
/entries
/entries/{KEY}DELETE method represent the delete or the drop command.
Examples:
curl -X DELETE http://localhost:12080/entries/hello
curl -X DELETE http://localhost:12080/entriesNotes
- It is 'originally' developed for code exercise. The requirements were; non-persistent, non-durable and supporting eviction.
Implementations
- Interactive mode
- RESTful API
- GET
- Collection (
/entries) - Element (
/entries/{KEY})
- Collection (
- PUT
- Collection (
/entries) - Element (
/entries/{KEY})
- Collection (
- POST
- Collection (
/entries) - Element (
/entries/{KEY})
- Collection (
- DELETE
- Collection (
/entries) - Element (
/entries/{KEY})
- Collection (
- GET
###License
Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.
9 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago