Class: ActiveFedora::CachingConnection
- Inherits:
 - 
      Ldp::Client
      
        
- Object
 - Ldp::Client
 - ActiveFedora::CachingConnection
 
 
- Defined in:
 - lib/active_fedora/caching_connection.rb
 
Instance Method Summary collapse
- 
  
    
      #cache  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Enable the cache within the block.
 - #clear_cache ⇒ Object
 - #disable_cache! ⇒ Object
 - #enable_cache! ⇒ Object
 - #get(url, options = {}) ⇒ Object
 - 
  
    
      #initialize(host, options = {})  ⇒ CachingConnection 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of CachingConnection.
 - #patch ⇒ Object
 - #post ⇒ Object
 - #put ⇒ Object
 - 
  
    
      #uncached  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Disable the query cache within the block.
 
Constructor Details
#initialize(host, options = {}) ⇒ CachingConnection
Returns a new instance of CachingConnection.
      3 4 5 6 7  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 3 def initialize(host, = {}) super @cache = {} @cache_enabled = false end  | 
  
Instance Method Details
#cache ⇒ Object
Enable the cache within the block.
      33 34 35 36 37 38 39 40  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 33 def cache old = @cache_enabled @cache_enabled = true yield ensure @cache_enabled = old clear_cache unless @cache_enabled end  | 
  
#clear_cache ⇒ Object
      59 60 61  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 59 def clear_cache @cache.clear end  | 
  
#disable_cache! ⇒ Object
      46 47 48  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 46 def disable_cache! @cache_enabled = false end  | 
  
#enable_cache! ⇒ Object
      42 43 44  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 42 def enable_cache! @cache_enabled = true end  | 
  
#get(url, options = {}) ⇒ Object
      9 10 11 12 13 14 15  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 9 def get(url, = {}) if @cache_enabled cache_resource(url) { super } else log(url) { super } end end  | 
  
#patch ⇒ Object
      27 28 29 30  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 27 def patch(*) clear_cache if @cache_enabled super end  | 
  
#post ⇒ Object
      17 18 19 20  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 17 def post(*) clear_cache if @cache_enabled super end  | 
  
#put ⇒ Object
      22 23 24 25  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 22 def put(*) clear_cache if @cache_enabled super end  | 
  
#uncached ⇒ Object
Disable the query cache within the block.
      51 52 53 54 55 56 57  | 
    
      # File 'lib/active_fedora/caching_connection.rb', line 51 def uncached old = @cache_enabled @cache_enabled = false yield ensure @cache_enabled = old end  |