Skip to content

Instantly share code, notes, and snippets.

View horatio-sans-serif's full-sized avatar
😡

Old Yeller horatio-sans-serif

😡
View GitHub Profile
var sys = require('sys'),
net = require('net'),
server = net.createServer(function (c) {
var input = '';
c.setEncoding('utf8');
c.addListener("data", function (chunk) {
input += chunk;
var match;
while (match = input.match(/^(.+)\r\n/)) {
input = input.substr(match[0].length);
~/projects/redis-node-client(master) ⚡ redis-cli set test:c a
OK
~/projects/redis-node-client(master) ⚡ redis-cli set 'test: d' b
OK
~/projects/redis-node-client(master) ⚡ redis-cli keys '*'
1. "test:c"
2. "test: d"
They both write the same value when the node script uses a Buffer.
~/Downloads/2010-05-07/compatibility_issue ⚡ redis-cli flushall
OK
~/Downloads/2010-05-07/compatibility_issue ⚡ !node
node write_file_to_redis.js 2> output.node
~/Downloads/2010-05-07/compatibility_issue ⚡ redis-cli get test_key
"\x1f\x8b\b\b\x80\xce\xe3K\x00\x03testfile.txt\x00\x0b\xc9\xc8,V\x00\xa2\xe2\xfc\xdcT\x85\x94\xc4\x92D\x85\x92\x8c\xc4\x12\x90Hz~f^\xbaBI\xbeBR\xaaBr~nAQjqqj\n\x17\x00\xc8\xcerT1\x00\x00\x00"
$ NODE_PATH=/Users/brian/projects/redis-node-client/lib:$NODE_PATH node test-mget.js
DEBUG: [ENQUEUE] Not connected. Request queued. There are 1 requests queued.
DEBUG: [FLUSH QUEUE] 1 queued request buffers.
DEBUG: [ENQUEUE] Not connected. Request queued. There are 2 requests queued.
DEBUG: [FLUSH QUEUE] 2 queued request buffers.
DEBUG: [ENQUEUE] Not connected. Request queued. There are 3 requests queued.
DEBUG: [CONNECT]
DEBUG: [FLUSH QUEUE] 3 queued request buffers.
DEBUG: [DEQUEUE/SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>foo<CRLF>$3<CRLF>bar<CRLF>. queued buffers remaining = 2
DEBUG: [DEQUEUE/SEND] *3<CRLF>$3<CRLF>set<CRLF>$3<CRLF>baz<CRLF>$3<CRLF>buz<CRLF>. queued buffers remaining = 1
$ node /tmp/foo.js
23 Apr 16:34:09 - system memory total 368864 KB
23 Apr 16:34:10 - peak RSS 6264 KB (2% of total)
23 Apr 16:34:10 - private memory (current) 5304 KB (1% of total)
23 Apr 16:34:11 - peak RSS 6752 KB (2% of total) (grew by 488 KB)
23 Apr 16:34:11 - private memory (current) 5796 KB (2% of total) (grew by 492 KB)
23 Apr 16:34:12 - peak RSS 6816 KB (2% of total) (grew by 64 KB)
23 Apr 16:34:12 - private memory (current) 5864 KB (2% of total) (grew by 68 KB)
23 Apr 16:34:13 - peak RSS 6884 KB (2% of total) (grew by 68 KB)
23 Apr 16:34:13 - private memory (current) 5928 KB (2% of total) (grew by 64 KB)
$ file /proc/14207/smaps
/proc/14207/smaps: empty
$ tail /proc/14207/smaps
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 8 kB
bf9cc000-bf9e2000 rw-p bf9cc000 00:00 0 [stack]
Size: 88 kB
Rss: 32 kB
var fs = require("fs");
sys = require("sys");
if (process.platform.toLowerCase().indexOf("linux") == -1)
throw new Error("unsupported platform");
setInterval(function () {
fs.readFile("/proc/" + process.pid + "/status", function (err, data) {
if (err) {
sys.puts(err);
~/projects/redis-node-client(master) ⚡ node test/phillip.js
DEBUG: [ENQUEUE] Not connected. Request queued. There are 1 requests queued.
DEBUG: [CONNECT]
DEBUG: [FLUSH QUEUE] 1 queued request buffers.
DEBUG: [DEQUEUE/SEND] *3<CRLF>$3<CRLF>set<CRLF>$8<CRLF>test:foo<CRLF>$3<CRLF>bar<CRLF>. queued buffers remaining = 0
DEBUG: [RECV] +OK<CRLF>
21 Apr 16:10:20 - set test:foo: true
DEBUG: [NO CONNECTION]
DEBUG: CLOSED -- false
21 Apr 16:10:25 - timeout fired
~/projects/redis-node-client(master) ⚡ ./test/test_shutdown_reconnect.js
DEBUG: [CONNECT]
DEBUG: [SEND] *2<CRLF>$3<CRLF>del<CRLF>$3<CRLF>foo<CRLF> originalCommands = 1 COUNT = 1
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 2 COUNT = 2
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 3 COUNT = 3
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 4 COUNT = 4
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 5 COUNT = 5
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 6 COUNT = 6
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 7 COUNT = 7
DEBUG: [SEND] *2<CRLF>$4<CRLF>incr<CRLF>$3<CRLF>foo<CRLF> originalCommands = 8 COUNT = 8
~ ⚡ node /tmp/readself.js
contents length = 551
buffer length before write = 551
buffer length after write = 551
not the same
contents
// file start
sys=require("sys");
fs=require("fs");
Buffer=require("buffer").Buffer;