module Middleware
class DatabasePinning
PIN_WINDOW = 5.seconds
def initialize(app)
@app = app
class Post < ApplicationRecord
has_many :comments, dependent: :destroy
# comments_count is maintained by counter_cache on Comment#belongs_to
scope :stale_comment_counts, lambda {
class CounterFlushJob
include Sidekiq::Job
sidekiq_options queue: :counters, retry: 3
def perform
CounterBuffer.flush_all.each do |field, delta|
package com.example.orders.event;
import java.math.BigDecimal;
import java.time.Instant;
public final class OrderPlacedEvent {