标签:
1 wget http://download.redis.io/releases/redis-3.0.7.tar.gz 2 tar -xvzf redis-3.0.7.tar.gz 3 cd redis-3.0.7 4 make 5 make install
mkdir /usr/local/redis cp -rf ./src/redis-cli ./src/redis-server ./redis.conf /usr/local/redis/ cd /usr/local/redis/
daemonize yes pidfile /var/run/redis.pid port 6379
REDISPORT=6379
EXEC=/usr/local/redis/redis-server
CLIEXEC=/usr/local/redis/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
chmod +x /etc/init.d/redis chkconfig --add redis chkconfig redis on
/usr/local/redis/redis-cli flushall /usr/local/redis/redis-cli -n 0 keys ‘*‘ /usr/local/redis/redis-cli -n 0 dbsize /usr/local/redis/redis-cli -n 0 flushdb /usr/local/redis/redis-cli -n 0 keys ‘*‘ | wc -l

1 $cache = new Redis; 2 $cache->connect(‘192.168.56.102‘, 6379); 3 $cache->set("test", "hello redis"); 4 var_dump($cache->get("test"));
标签:
原文地址:http://www.cnblogs.com/helingfeng/p/5854483.html