Sha256: e9156eae53afae61e16f694858b800061eff9d1f27e383fa08e782ea25ac6ea3
Contents?: true
Size: 1.93 KB
Versions: 6
Compression:
Stored size: 1.93 KB
Contents
# DiskCache [](https://travis-ci.org/propertybase/disk_cache) [](https://codeclimate.com/github/propertybase/disk_cache) What does it do? You give DiskCache the URL of a file and DiskCache makes sure that it has the file stored on disk. You can retrieve your files with the same URL you used to save the file. ## Installation Add this line to your application's Gemfile: gem 'disk_cache' And then execute: $ bundle Or install it yourself as: $ gem install disk_cache ## Usage ```ruby # to save an image in the cache DiskCache.put('http://example.com/1234abc.jpg') #=> nil # to get an image from the cache DiskCache.get('http://example.com/1234abc.jpg') #=> #<File:1234abc.jpg> # or #=> nil # if the file isn't stored in the cache # to get a file no matter if it was stored in the cache or not # this will get the file from disk or download it and save it in the cache DiskCache.pget('http://example.com/1234abc.jpg') #=> #<File:1234abc.jpg> # to delete an image from the cache DiskCache.del('http://example.com/1234abc.jpg') #=> nil ``` ## Ideas - option to check if an image has changed (i.e. HTTP Last-Modified) ```ruby Net::HTTP.start("example.com") do |http| response = http.request_head('/1352127364208.png') puts response['Last-Modified'] end ``` - option to change the path of the cache - option to force a .put, i.e. overwrite - option to set the depth of subfolders - option to set the Hashing algorithm (e.g. MD5, SHA1, SHA2, etc) ## Contributing 1. Fork it 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 new Pull Request ## License License is MIT, see [LICENSE.txt](https://github.com/propertybase/disk_cache/blob/master/LICENSE.txt) for details.
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
disk_cache-0.0.8 | README.md |
disk_cache-0.0.7 | README.md |
disk_cache-0.0.6 | README.md |
disk_cache-0.0.5 | README.md |
disk_cache-0.0.4 | README.md |
disk_cache-0.0.3 | README.md |