This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.rb filter=whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test {ZMERGE} { | |
$r del zseta zsetb zsetc | |
$r zadd zseta 1 a | |
$r zadd zseta 2 b | |
$r zadd zseta 3 c | |
$r zadd zsetb 1 b | |
$r zadd zsetb 2 c | |
$r zadd zsetb 3 d | |
list [$r zmerge zsetc zseta zsetb] [$r zrange zsetc 0 -1 withscores] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this scopes the contents to the current spec | |
// doesn't matter if callback is fired way later than timeout | |
it "should work" | |
var contents | |
fs.readFile('foo', function(err, c){ | |
contents = c | |
}) | |
wait(-{ | |
contents.should.eql 'bar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'grit' | |
include Grit | |
repo = Repo.new('.') | |
repo.commits('master', false).each do |commit| | |
sha = commit.id | |
blob = repo.tree(sha) / 'redis.c' | |
contents = blob.data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hash dereference in SORT | |
$ ./redis-cli hset user:1 name john | |
(integer) 1 | |
$ ./redis-cli hset user:2 name jane | |
(integer) 1 | |
$ ./redis-cli rpush users 1 | |
(integer) 1 | |
$ ./redis-cli rpush users 2 | |
(integer) 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mockup of test suite for redis integration testing | |
# Author: Pieter Noordhuis | |
require 'tempfile' | |
require 'test/unit' | |
class Config | |
DEFAULT = File.join(File.dirname(__FILE__), 'redis.conf') | |
def initialize(&blk) | |
@configuration = defaults.dup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example (working) test for testing Redis replication | |
start_server default.conf {} { | |
r set mykey foo | |
start_server default.conf {} { | |
test {SLAVEOF should sync} { | |
r slaveof [srv -1 host] [srv -1 port] | |
wait_for_sync r | |
r get mykey | |
} {foo} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./ziplist | |
{bytes 10} {length 1} | |
{key 3}foo | |
{end} | |
{bytes 15} {length 2} | |
{key 3}foo | |
{key 4}quux | |
{end} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$redis = new Redis(); | |
$redis->connect('127.0.0.1', 6379); | |
for ($i = 0; $i < 100; $i++) { | |
$start = microtime(true); | |
for ($j = 0; $j < 10000; $j++) { | |
$key = sprintf("key:%05d", $j); | |
/* GET or SET */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Pieter Noordhuis | |
# Description: Sample script to write a Redis feed to an append-only file | |
# | |
# Requires the eventmachine gem. | |
# Warning: don't use this unless you know what you're doing! | |
# | |
require 'eventmachine' | |
require 'stringio' |