Sha256: 8e505c0bfbb9ece3ff0d5395d406e1807435526de5919f833d52b98ca9a8c319
Contents?: true
Size: 923 Bytes
Versions: 6
Compression:
Stored size: 923 Bytes
Contents
require 'pstore' module FeedTorrents def self.store Store.instance end class Store include Singleton include LogFunctions def present?(item) pstore.transaction(true) { return !!pstore[item] } end def persist(item) pstore.transaction { pstore[item] = Time.now.to_i } end def prune prune_count = 0 pstore.transaction do pstore.roots.each do |item| if outdated?(item) pstore.delete(item) prune_count += 1 end end end if prune_count > 0 info "Pruned #{prune_count} items" end end private def pstore @pstore ||= PStore.new(pstore_file) end def pstore_file File.expand_path(FeedTorrents.configuration.datastore) end def outdated?(time) (Time.now.to_i - time.to_i < 7776000) # older than 90 days is outdated end end end
Version data entries
6 entries across 6 versions & 1 rubygems