Class: OnlineGHAProvider::Cache
- Inherits:
-
Object
- Object
- OnlineGHAProvider::Cache
- Defined in:
- lib/gh-archive.rb
Instance Method Summary collapse
- #full? ⇒ Boolean
- #get(name) ⇒ Object
- #has?(name) ⇒ Boolean
-
#initialize(max_size = 10) ⇒ Cache
constructor
A new instance of Cache.
- #put(name, content) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(max_size = 10) ⇒ Cache
365 366 367 368 369 |
# File 'lib/gh-archive.rb', line 365 def initialize(max_size = 10) @cache = {} @max_size = max_size @mutex = Mutex.new end |
Instance Method Details
#full? ⇒ Boolean
393 394 395 |
# File 'lib/gh-archive.rb', line 393 def full? self.size >= @max_size end |
#get(name) ⇒ Object
377 378 379 380 381 |
# File 'lib/gh-archive.rb', line 377 def get(name) @mutex.synchronize do return @cache.delete(name) end end |
#has?(name) ⇒ Boolean
389 390 391 |
# File 'lib/gh-archive.rb', line 389 def has?(name) return @cache.has_key?(name) end |
#put(name, content) ⇒ Object
371 372 373 374 375 |
# File 'lib/gh-archive.rb', line 371 def put(name, content) @mutex.synchronize do @cache[name] = content end end |
#size ⇒ Object
383 384 385 386 387 |
# File 'lib/gh-archive.rb', line 383 def size @mutex.synchronize do return @cache.size end end |