Skip to content

Instantly share code, notes, and snippets.

*.rb filter=whitespace
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 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'
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
# 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
# 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
# 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}
}
$ ./ziplist
{bytes 10} {length 1}
{key 3}foo
{end}
{bytes 15} {length 2}
{key 3}foo
{key 4}quux
{end}
<?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 */
# 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'