Class: Jekyll::ArchiveLink::TmpDirCache
- Inherits:
-
Object
- Object
- Jekyll::ArchiveLink::TmpDirCache
- Defined in:
- lib/jekyll/archive_link/tmp_dir_cache.rb
Constant Summary collapse
- TMP_DIR =
"./tmp/jekyll-archive_link/cache"
Instance Method Summary collapse
Instance Method Details
#delete(url) ⇒ Object
30 31 32 33 34 |
# File 'lib/jekyll/archive_link/tmp_dir_cache.rb', line 30 def delete(url) key = cache_key(url) path = path_for_file_with_key(key) FileUtils.rm(path) end |
#read(url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jekyll/archive_link/tmp_dir_cache.rb', line 10 def read(url) key = cache_key(url) path = path_for_file_with_key(key) if File.exist?(path) Jekyll::ArchiveLink.debug "HIT: Cache read #{url}" JSON.parse File.read(path) else Jekyll::ArchiveLink.debug "MISS: Cache read #{url}" nil end end |
#write(url, value) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/jekyll/archive_link/tmp_dir_cache.rb', line 22 def write(url, value) Jekyll::ArchiveLink.debug "Cache write: #{url}, value: #{value}" key = cache_key(url) path = path_for_file_with_key(key) FileUtils.mkdir_p(TMP_DIR) File.binwrite(path, value) end |