Module: SolidCache::Cluster::Expiry
- Included in:
- SolidCache::Cluster
- Defined in:
- lib/solid_cache/cluster/expiry.rb
Defined Under Namespace
Classes: Counter
Constant Summary collapse
- EXPIRY_MULTIPLIER =
For every write that we do, we attempt to delete EXPIRY_MULTIPLIER times as many records. This ensures there is downward pressure on the cache size while there is valid data to delete
1.25
Instance Attribute Summary collapse
-
#expire_every ⇒ Object
readonly
Returns the value of attribute expire_every.
-
#expiry_batch_size ⇒ Object
readonly
Returns the value of attribute expiry_batch_size.
-
#expiry_method ⇒ Object
readonly
Returns the value of attribute expiry_method.
-
#max_age ⇒ Object
readonly
Returns the value of attribute max_age.
-
#max_entries ⇒ Object
readonly
Returns the value of attribute max_entries.
Instance Method Summary collapse
Instance Attribute Details
#expire_every ⇒ Object (readonly)
Returns the value of attribute expire_every.
10 11 12 |
# File 'lib/solid_cache/cluster/expiry.rb', line 10 def expire_every @expire_every end |
#expiry_batch_size ⇒ Object (readonly)
Returns the value of attribute expiry_batch_size.
10 11 12 |
# File 'lib/solid_cache/cluster/expiry.rb', line 10 def expiry_batch_size @expiry_batch_size end |
#expiry_method ⇒ Object (readonly)
Returns the value of attribute expiry_method.
10 11 12 |
# File 'lib/solid_cache/cluster/expiry.rb', line 10 def expiry_method @expiry_method end |
#max_age ⇒ Object (readonly)
Returns the value of attribute max_age.
10 11 12 |
# File 'lib/solid_cache/cluster/expiry.rb', line 10 def max_age @max_age end |
#max_entries ⇒ Object (readonly)
Returns the value of attribute max_entries.
10 11 12 |
# File 'lib/solid_cache/cluster/expiry.rb', line 10 def max_entries @max_entries end |
Instance Method Details
#initialize(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/solid_cache/cluster/expiry.rb', line 12 def initialize( = {}) super() @expiry_batch_size = .fetch(:expiry_batch_size, 100) @expiry_method = .fetch(:expiry_method, :thread) @expire_every = [ (expiry_batch_size / EXPIRY_MULTIPLIER).floor, 1 ].max @max_age = .fetch(:max_age, 2.weeks.to_i) @max_entries = .fetch(:max_entries, nil) raise ArgumentError, "Expiry method must be one of `:thread` or `:job`" unless [ :thread, :job ].include?(expiry_method) end |
#track_writes(count) ⇒ Object
23 24 25 |
# File 'lib/solid_cache/cluster/expiry.rb', line 23 def track_writes(count) expire_later if expiry_counter.count(count) end |