module CollectionCacheKey
extend ActiveSupport::Concern
def cache_key_for(scope)
relation = scope.respond_to?(:all) ? scope.all : scope
model = relation.klass
import { useState, useMemo, useCallback } from 'react'
import { Post } from '@/types'
import { PostCard } from './PostCard'
interface FilteredPostsProps {
posts: Post[]
use std::collections::HashMap;
use std::hash::Hash;
use std::sync::{Arc, RwLock};
pub struct Memoizer<K, V> {
store: RwLock<HashMap<K, Arc<V>>>,
class RevenueStat
DEFAULT_RANGE = 30.days
def initialize(account, range: DEFAULT_RANGE)
@account = account
@range = range
import { useMemo } from "react";
export type SortDir = "asc" | "desc";
export interface SortConfig<T> {
key: keyof T;
dir: SortDir;
module Cacheable
extend ActiveSupport::Concern
def cache_query(prefix, scope, expires_in: 15.minutes)
key = [prefix, cache_version_token(scope)].join("/")
class PriceBreakdown < Struct.new(:subtotal_cents, :discount_cents, :tax_cents, keyword_init: true)
def initialize(*)
super
freeze
end
module RequestStore
def self.store
Thread.current[:request_store] ||= {}
end
def self.fetch(key)
import functools
import threading
import time
from collections import OrderedDict