Skip to content

Instantly share code, notes, and snippets.

View rbraband's full-sized avatar

Roland Braband rbraband

  • Nordmann, Rassmann GmbH
  • DE - Hamburg
View GitHub Profile
<?php
// constants
define('WITHSCORES', true);
define('REDIS_CONNECTION', ((CLI) ? '/var/run/redis.socket' : '127.0.0.1')); // localhost or socket
#define('REDIS_CONNECTION', '127.0.0.1'); // localhost only
define('REDIS_NAMESPACE', 'lou:'); // use custom prefix on all keys
define('REDIS_DB', 1);
#define('REDIS_AUTH', '');
define('REDIS_LOG_FILE', ((CLI) ? $_SERVER['PWD'] : $_SERVER['DOCUMENT_ROOT']).'/logs/redis.txt');
@rbraband
rbraband / example 1
Created February 24, 2012 14:12
Howto implement stored procedures within Redis
# Step 0 -- create test data
redis-cli HSET :object:30343552:data foo bar
# Step 1 -- store sample function 'sampleFunction'
redis-cli SET :functions:sample "redis.call('SELECT', 0);local data=redis.call('HGETALL',':object:' .. ARGV[1] .. ':data');return data"
# Step 2 -- create function loader
redis-cli SCRIPT LOAD "f=loadstring(redis.call('get',':functions:' .. KEYS[1]));return f()"
# Step 3 -- test