Sha256: 60a6d79101a8b495379afbc3e61fc13debacaaa7c69972aabe2a36030e34fc54
Contents?: true
Size: 802 Bytes
Versions: 23
Compression:
Stored size: 802 Bytes
Contents
require 'rest-core' YourClient = RC::Builder.client do use RC::DefaultSite , 'https://api.github.com/users/' use RC::JsonResponse, true use RC::CommonLogger, method(:puts) use RC::Cache , nil, 3600 end YourClient.pool_size = 5 client = YourClient.new(:cache => {}) p client.get('godfat') # cache miss puts p client.get('godfat') # cache hit client.cache = false puts "concurrent requests" a = [client.get('godfat'), client.get('cardinalblue')] puts "It's not blocking... but doing concurrent requests underneath" p a.map{ |r| r['name'] } # here we want the values, so it blocks here puts "DONE" puts "callback" client.get('godfat'){ |v| p v } puts "It's not blocking... but doing concurrent requests underneath" client.wait # we block here to wait for the request done puts "DONE"
Version data entries
23 entries across 23 versions & 1 rubygems