共有 0 个贴子
没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
oss.trustie.net/open_source_projects | 主页 > 开源项目社区 > callcache |
callcache
|
0 | 0 | 7 |
贡献者 | 讨论 | 代码提交 |
A simple Ruby library for caching the results of a call to any method or function call.
Great for speeding up program execution for when making long calls to things like web services.
Examplerequire 'call_cache'
require 'net/http'
def exp_fun( start_num, end_num )
ret_val = 1
start_num.upto( end_num ) do |num|
ret_val = ret_val * num
end
return ret_val.to_s.size
end
blog_source = CallCache.call( 'Net::HTTP.get', :pars => [URI.parse('http://feeds.feedburner.com/adamw523?format=xml')] )
p blog_source.size
p CallCache.call( 'exp_fun', :pars => [1, 10000], :options => {:ttl => 10})