Class: Liquid2::ThreadSafeLRUCache

Inherits:
LRUCache
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/liquid2/utils/cache.rb

Overview

A thread safe least recently used cache.

Instance Attribute Summary

Attributes inherited from LRUCache

#max_size

Instance Method Summary collapse

Constructor Details

#initialize(max_size = 128) ⇒ ThreadSafeLRUCache

Returns a new instance of ThreadSafeLRUCache.



52
53
54
# File 'lib/liquid2/utils/cache.rb', line 52

def initialize(max_size = 128)
  super
end

Instance Method Details

#[](key) ⇒ Object



56
57
58
59
60
# File 'lib/liquid2/utils/cache.rb', line 56

def [](key)
  synchronize do
    unsafe_get(key)
  end
end

#[]=(key, value) ⇒ Object



62
63
64
65
66
# File 'lib/liquid2/utils/cache.rb', line 62

def []=(key, value)
  synchronize do
    unsafe_set(key, value)
  end
end

#keysObject



74
75
76
77
78
# File 'lib/liquid2/utils/cache.rb', line 74

def keys
  synchronize do
    unsafe_keys
  end
end

#lengthObject



68
69
70
71
72
# File 'lib/liquid2/utils/cache.rb', line 68

def length
  synchronize do
    unsafe_length
  end
end

#unsafe_getObject



47
# File 'lib/liquid2/utils/cache.rb', line 47

alias unsafe_get []

#unsafe_keysObject



50
# File 'lib/liquid2/utils/cache.rb', line 50

alias unsafe_keys keys

#unsafe_lengthObject



49
# File 'lib/liquid2/utils/cache.rb', line 49

alias unsafe_length length

#unsafe_setObject



48
# File 'lib/liquid2/utils/cache.rb', line 48

alias unsafe_set []=