-
-
Save gr33n7007h/ed075f2b9fc6eccbadb52f0671309854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'typhoeus' | |
class Cache | |
def initialize | |
@memory = {} | |
end | |
def get(request) | |
@memory[request] | |
end | |
def set(request, response) | |
@memory[request] = response | |
end | |
end | |
Typhoeus::Config.cache = Cache.new | |
p Typhoeus.get('www.example.com', cache_ttl: 1).cached? #=> false | |
Kernel.sleep(2) | |
p Typhoeus.get('www.example.com').cached? # this would be true without cache_ttl #=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment