Class: Atompub::SimpleCache

Inherits:
AbstractCache show all
Defined in:
lib/atomutil.rb

Overview

Atompub::SimpleCache

Basic cache storage class. Use Hash object to store data.

Constant Summary collapse

@@singleton =

singleton closure

nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSimpleCache

initializer



1190
1191
1192
# File 'lib/atomutil.rb', line 1190

def initialize
  @cache = Hash.new
end

Class Method Details

.instanceObject

Get singleton instance



1185
1186
1187
1188
# File 'lib/atomutil.rb', line 1185

def self.instance
  @@singleton = self.new if @@singleton.nil?
  @@singleton
end

Instance Method Details

#get(uri) ⇒ Object

Pick cache resource from hash for indicated uri.



1194
1195
1196
# File 'lib/atomutil.rb', line 1194

def get(uri)
  @cache.has_key?(uri) ? @cache[uri] : nil
end

#put(uri, params) ⇒ Object

Set cache resource into hash.



1198
1199
1200
# File 'lib/atomutil.rb', line 1198

def put(uri, params)
  @cache[uri] = CacheResource.new(params)
end