semi-transparent memoization; backed by redis;
writes are sent to the master, reads are sent to an approriate slave.
Two features:
-
Memodis#memoize
-
Memodis::DistCache
def fib(num) return num if num < 2 fib(num - 1) + fib(num - 2) end puts "Before memoize: " puts fib(33) => 3524578 # after ~ 7 seconds extend Memodis memoize :fib, Memodis::DistCache.new({ :key_gen => lambda { |k| "fib(#{k})" }, :decoder => :integer, :expires => (10 * 60), :master => '127.0.0.1:16379 127.0.0.1:16380'.split, :slaves => '127.0.0.1:16389 127.0.0.1:16390 127.0.0.1:16391 127.0.0.1:16392 127.0.0.1:16393 127.0.0.1:16394'.split }) puts "After memoize: " puts fib(33) => 3524578 # after ~ 0.03 seconds puts fib(33) => 3524578 # after ~ 0.0001 seconds puts fib(33) => 3524578 # after ~ 0.0001 seconds
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 [email protected]. See LICENSE for details.