File: active_support/cache/synchronized_memory_store.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: ActiveSupport#1
  module: Cache#2
  class: SynchronizedMemoryStore#4
inherits from
  MemoryStore ( ActiveSupport::Cache )
has properties
method: initialize #5
method: fetch / 2 #10
method: read / 2 #14
method: write / 3 #18
method: delete / 2 #22
method: delete_matched / 2 #26
method: exist? / 2 #30
method: increment / 2 #34
method: decrement / 2 #38
method: clear #42

Code

   1  module ActiveSupport
   2    module Cache
   3      # Like MemoryStore, but thread-safe.
   4      class SynchronizedMemoryStore < MemoryStore
   5        def initialize
   6          super
   7          @guard = Monitor.new
   8        end
   9 
  10        def fetch(key, options = {})
  11          @guard.synchronize { super }
  12        end
  13 
  14        def read(name, options = nil)
  15          @guard.synchronize { super }
  16        end
  17 
  18        def write(name, value, options = nil)
  19          @guard.synchronize { super }
  20        end
  21 
  22        def delete(name, options = nil)
  23          @guard.synchronize { super }
  24        end
  25 
  26        def delete_matched(matcher, options = nil)
  27          @guard.synchronize { super }
  28        end
  29 
  30        def exist?(name,options = nil)
  31          @guard.synchronize { super }
  32        end
  33 
  34        def increment(key, amount = 1)
  35          @guard.synchronize { super }
  36        end
  37 
  38        def decrement(key, amount = 1)
  39          @guard.synchronize { super }
  40        end
  41 
  42        def clear
  43          @guard.synchronize { super }
  44        end
  45      end
  46    end
  47  end