New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prefetcher

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prefetcher

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Prefetcher

Build Status Code Climate Test Coverage

This gem provides a simple-to-use interface to work with frequently requested http requests from your api. It gets request response from memory, if possible. But also this means you have to update this cache from time to time (using whenever, for example). Any kind of non-200 responses will not be memoized, so you can be always sure that you don't use broken data. Redis is used to store data. RDoc

Installation

Add this line to your application's Gemfile:

gem 'prefetcher'

And then execute:

$ bundle

Or install it yourself as:

$ gem install prefetcher

You can also override redis connection details (if not using default localhost:6379 ):

Prefetcher.redis_connection = Redis.new(:host => "10.0.1.1", :port => 6380, :db => 15)

See redis gem documentation for more options when creating redis connection.

Usage

Using cached requests

After installing project you can request any URL:

Prefetcher::HttpPrefetcher.new('http://www.reddit.com/r/ruby').get

Calling #get any number of times will return data from cache.

Force get

If you want to force request (and save the response), you can call #fetch:

Prefetcher::HttpPrefetcher.new('http://www.reddit.com/r/ruby').fetch

This will cause actual http request.

Updating cache

Calling manualy. You can call Prefetcher.update_all to fetch all URLs right now.

You can also automate this call using whenever. Just add this code to your schedule.rb .

every 30.minutes do
  runner "Prefetcher.update_all"
end%

Contributing

  1. Fork it ( https://github.com/brain-geek/prefetcher/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

FAQs

Package last updated on 26 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc