Sha256: 53415b44c6a10e99d56af570e07107f05d8cb30c707bd4a857b34f08632f4dd2

Contents?: true

Size: 1.08 KB

Versions: 33

Compression:

Stored size: 1.08 KB

Contents

// Read a file from disk, store it in Redis, then read it back from Redis.

var redis = require("redis"),
    client = redis.createClient(),
    fs = require("fs"),
    filename = "kids_in_cart.jpg";

// Get the file I use for testing like this:
//    curl http://ranney.com/kids_in_cart.jpg -o kids_in_cart.jpg
// or just use your own file.

// Read a file from fs, store it in Redis, get it back from Redis, write it back to fs.
fs.readFile(filename, function (err, data) {
    if (err) throw err
    console.log("Read " + data.length + " bytes from filesystem.");
    
    client.set(filename, data, redis.print); // set entire file
    client.get(filename, function (err, reply) { // get entire file
        if (err) {
            console.log("Get error: " + err);
        } else {
            fs.writeFile("duplicate_" + filename, reply, function (err) {
                if (err) {
                    console.log("Error on write: " + err)
                } else {
                    console.log("File written.");
                }
                client.end();
            });
        }
    });
});

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/redis/examples/file.js
express_translate-1.0.13 node_modules/redis/examples/file.js
express_translate-1.0.12 node_modules/redis/examples/file.js
express_translate-1.0.11 node_modules/redis/examples/file.js