Skip to content

Instantly share code, notes, and snippets.

View nrk's full-sized avatar
🤔
はい、猫のように見えます。

Daniele Alessandri nrk

🤔
はい、猫のように見えます。
View GitHub Profile
@nrk
nrk / predis_0_6_x.php
Created April 18, 2011 17:50
Dirty trick to get a transaction instance out of a cluster of connections by using a particular key tag.
<?php
// Using Predis 0.6
require 'Predis.php';
$clusterClient = new Predis\Client(array(/* array of servers */));
// We use a fake command (e.g. GET) to obtain the actual connection out of a cluster
// that is responsible for our particular key tag (or a key, but *only* that one key).
@nrk
nrk / hops_lighttpd_fcgi_lua51_maxprocs1.txt
Created April 9, 2011 12:15
Benchmarking Hops with various configurations (spoiler: Mongrel2 + LuaJIT 2 == FAST!)
$ ab -n 1000 -c 50 http://10.1.1.82:80/hello/world
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 10.1.1.82 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@nrk
nrk / NamespacingProfile.php
Created April 4, 2011 21:54
Namespace Redis keys transparently using Predis v0.6.x
<?php
namespace Predis;
class NamespacingProfile extends RedisServerProfile {
private $_prefix;
private $_profile;
private $_strategies;
public function __construct($prefix, $profile = 'default') {
@nrk
nrk / predis_udp.php
Created April 3, 2011 10:54
Let's preserve the UdpConnection class from early versions of Predis v0.7-dev
// This is the old UdpConnection class used in early versions of Predis v0.7-dev to
// test the udp branch of Redis (which is now gone). I am keeping this class only
// for reference, it is not compatible with the current API design of Predis v0.7-dev
// and support for UDP is no more part of the future plans of Redis anyway.
class UdpConnection extends ConnectionBase {
private $_requestId, $_databaseId, $_authPwd;
private $_replyBuf, $_replyBufL, $_replyBufP;
public function __construct(ConnectionParameters $parameters, ResponseReader $reader = null) {
@nrk
nrk / predis-0_6_6-relnotes.markdown
Created April 1, 2011 19:37
Predis 0.6.6 (2011-04-01) - Release notes

Predis 0.6.6 (2011-04-01) - Release notes

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series that features mainly performance improvements and adds some new features. As with previous releases, Predis is also available for PHP 5.2 with an officially supported backport (PHP >= 5.2.6). What follows is an overview of the new features introduced in this new release. For a more in-depth list of changes please see the CHANGELOG.

Please read also the roadmap for future releases paragraph.

New features and changes

@nrk
nrk / predis-0_6_5-relnotes.markdown
Created February 12, 2011 20:56
Predis 0.6.5 (2011-02-12) - Release notes

Predis 0.6.5 (2011-02-12) - Release notes

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series exclusively aimed to fix a bug introduced in v0.6.4 when reading zero-length bulk replies from the server. For a complete list of the new features introduced in Predis v0.6.4 you can read the related release notes.

New features and changes

Fix for the zero-length bulk replies bug

@nrk
nrk / predis-0_6_4-relnotes.markdown
Created February 12, 2011 12:18
Predis 0.6.4 (2011-02-12) - Release notes

Predis 0.6.4 (2011-02-12) - Release notes

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series that features mainly performance improvements. As with previous releases, Predis is also available for PHP 5.2 with an officially supported backport (PHP >= 5.2.6). What follows is an overview of the new features introduced in this new release. For a more in-depth list of changes please see the CHANGELOG.

Please read also the roadmap for future releases paragraph.

New features and changes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ParserDriver
{
public class Parser
{
public string Method;
@nrk
nrk / predis-0_6_3-relnotes.markdown
Created January 1, 2011 17:21
Predis 0.6.3 (2011-01-01) - Release notes

Predis 0.6.3 (2011-01-01) - Release notes

Predis is a flexible and feature-complete PHP client library for Redis. This is a maintenance release for the 0.6 series that features support for check and set (CAS) operations using the Predis\MultiExecBlock abstraction for MULTI/EXEC transactions and the addition of the remaining commands that will be part of Redis 2.2 (now in the RC stage). As with previous releases, Predis is also available for PHP 5.2 with an officially supported backport (PHP >= 5.2.6). What follows is an overview of the new features introduced in this new release. For a more in-depth list of changes please see the CHANGELOG.

New features and changes

Transactions with CAS support

@nrk
nrk / zpop.lua
Created December 28, 2010 15:10
Implementation of ZPOP with redis-lua + CAS transactions
require 'luarocks.require'
require 'redis'
-- See "WATCH explained" from http://redis.io/topics/transactions
--[[
./redis-cli ZADD zset 1 a
./redis-cli ZADD zset 2 b
./redis-cli ZADD zset 3 c
]]