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



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

def initialize
  @cache = Hash.new
end

Class Method Details

.instanceObject

Get singleton instance



1182
1183
1184
1185
# File 'lib/atomutil.rb', line 1182

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.



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

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

#put(uri, params) ⇒ Object

Set cache resource into hash.



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

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