I've been trying to understand how to setup systems from
the ground up on Ubuntu. I just installed redis onto
the box and here's how I did it and some things to look
out for.
To install:
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: redis-server | |
| # Required-Start: $syslog | |
| # Required-Stop: $syslog | |
| # Should-Start: $local_fs | |
| # Should-Stop: $local_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: redis-server - Persistent key-value db |
| var EventEmitter = require("events").EventEmitter, | |
| redis = require("redis"), | |
| dateformat = require("dateformat"); | |
| function population32(x) | |
| { | |
| x -= ((x >> 1) & 0x55555555); | |
| x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); | |
| x = (((x >> 4) + x) & 0x0f0f0f0f); | |
| x += (x >> 8); |
| # create a new post | |
| rake new_post["title"] | |
| # re-build the site including any recent changes | |
| rake generate | |
| # run WEBrick server locally on port 4000 | |
| rake preview | |
| # push changes to github (master branch) |
原題:Dynamo: Amazon’s Highly Available Key-value Store
原文: Amazon's Dynamo - All Things Distributed (PDF Version)
This article is translated by @ono_matope. Please contact me if any problem.
| "use strict"; | |
| var express = require('express') | |
| , http = require('http') | |
| , path = require('path') | |
| , io = require('socket.io') | |
| , connect = require("express/node_modules/connect") | |
| , Session = express.session.Session | |
| , app = express(); | |
| //メモリストアかRedisのどちらかでセッションを保存 |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
| var cluster = require('cluster'); | |
| var PORT = +process.env.PORT || 1337; | |
| if (cluster.isMaster) { | |
| // In real life, you'd probably use more than just 2 workers, | |
| // and perhaps not put the master and worker in the same file. | |
| cluster.fork(); | |
| cluster.fork(); | |
| cluster.on('disconnect', function(worker) { |
| package Redis::Custom; | |
| use strict; | |
| use warnings; | |
| # Redis::Custom->setup_custom_command( $redis, 'sjaccardstore', $lua_script, 1 ); | |
| sub setup_custom_command { | |
| my ($package, $redis, $command_name, $lua_script, $key_count, @binded_values) = @_; | |
| my ($sha1) = $redis->script_load( $lua_script ); |
| module.exports = { | |
| format: 'json', | |
| apiVersion: '2013-11-04', | |
| endpointPrefix: 'kinesis', | |
| jsonVersion: '1.1', | |
| serviceFullName: 'Amazon Kinesis', | |
| signatureVersion: 'v4', | |
| targetPrefix: 'Kinesis_20131104', | |
| timestampFormat: 'iso8601', | |
| operations: { |