1#!/usr/bin/ruby 2# 3# construct the blocklist in memcache for testing 4# 5 6# for use with memcache-client 1.5.x 7 8require 'rubygems' 9require 'memcache' 10 11@servers = [ 'localhost:11211' ] 12 13@options = { 14 :prefix_key => '', 15 :hash => :default, 16 :distribution => :modula 17} 18 19@cache = MemCache.new(@servers,@options) 20# 21# per robey: marshall must be set to false otherwise we'll feed marshalled data to apache 22# and apache doesn't work with marshalled data. 23# 24@cache.set("mb:b:1",'127.0.0.0-127.0.0.99',0,true) 25@cache.set("mb:b:2",'127.0.0.0/24',0,true) 26@cache.set("mb:b:3",'127.0.0.1',0,true) 27# ipv6 28@cache.set("mb:b:4",'::1',0,true) 29 30# whitelisting - takes precendence 31# @cache.set("mb:w:4",'::1',0,true) 32 33puts "blocks set:" 34for x in 1..4 35 puts "#{x} = " + @cache.get("mb:b:#{x}",true) 36end 37