Sha256: 127a243969d9c90c34e3b0049425fc757434ffb16f64c7a684a447c12990e069
Contents?: true
Size: 919 Bytes
Versions: 15
Compression:
Stored size: 919 Bytes
Contents
require 'date' module Alephant module Publisher module SQSHelper class Archiver attr_reader :cache, :async def initialize(cache, async = true) @async = async @cache = cache end def see(message) return if message.nil? message.tap { |m| async ? async_store(m) : store(m) } end private def async_store(m) Thread.new { store(m) } end def store(m) cache.put("archive/#{date_key}/#{m.id}", m.body, meta_for(m)) end def date_key DateTime.now.strftime('%d-%m-%Y_%H') end def meta_for(m) { :id => m.id, :md5 => m.md5, :logged_at => DateTime.now.to_s, :queue => m.queue.url, } end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems