Sha256: b200f8590f8f1f1a88be9030dc435ebf83e0fa4dc6360a396e808a9898246e2d
Contents?: true
Size: 623 Bytes
Versions: 7
Compression:
Stored size: 623 Bytes
Contents
# frozen_string_literal: true module SolidCable class TrimJob < ActiveJob::Base def perform return unless trim? ::SolidCable::Message.transaction do ids = ::SolidCable::Message.trimmable.non_blocking_lock. limit(trim_batch_size).pluck(:id) ::SolidCable::Message.where(id: ids).delete_all end end private def trim_batch_size ::SolidCable.trim_batch_size end def trim? expires_per_write = (1 / trim_batch_size.to_f) * ::SolidCable.trim_chance rand < (expires_per_write - expires_per_write.floor) end end end
Version data entries
7 entries across 7 versions & 1 rubygems