Class: Atompub::SimpleCache
- Inherits:
-
AbstractCache
- Object
- AbstractCache
- Atompub::SimpleCache
- 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 ⇒ Object
Get singleton instance.
Instance Method Summary collapse
-
#get(uri) ⇒ Object
Pick cache resource from hash for indicated uri.
-
#initialize ⇒ SimpleCache
constructor
initializer.
-
#put(uri, params) ⇒ Object
Set cache resource into hash.
Constructor Details
#initialize ⇒ SimpleCache
initializer
1190 1191 1192 |
# File 'lib/atomutil.rb', line 1190 def initialize @cache = Hash.new end |
Class Method Details
.instance ⇒ Object
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 |