Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phoet/file_cache
Simple caching-utility for persisting arbitrary data in a file.
https://github.com/phoet/file_cache
Last synced: 26 days ago
JSON representation
Simple caching-utility for persisting arbitrary data in a file.
- Host: GitHub
- URL: https://github.com/phoet/file_cache
- Owner: phoet
- Created: 2009-09-06T14:11:13.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2009-10-27T20:03:25.000Z (about 15 years ago)
- Last Synced: 2024-05-01T22:35:53.048Z (6 months ago)
- Language: Ruby
- Homepage: http://blog.nofail.de/
- Size: 89.8 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
README
= FileCache
Simple caching utility that persists arbitrary data in files.
== Install
$ gem install phoet-file_cache -s http://gems.github.com
== How to use
Just include the FileCache module and use the provided +file_cache+ method
include FileCache
[...]
file_cache :the_name_of_the_action_you_execute do
#some stuff that should be cached, an external API call f.e.
endThe block you are providing is only executed if there is no cache-data provided or if the cache is expired.
By default, the cache expires after half an hour, but you can override this behavior by passing in time you want the content to be cached as a second argument.file_cache :the_name_of_the_action_you_execute, 60 do ...
FileCache persists the return-value of the given block in a file in your local +tmpfolder+.
You may override this behavior by setting the +file_cache_dir+.self.file_cache_dir='path_to_other_dir'