Module: SolidCache::Store::Expiry
- Included in:
- SolidCache::Store
- Defined in:
- lib/solid_cache/store/expiry.rb
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
2
Instance Attribute Summary collapse
-
#expires_per_write ⇒ Object
readonly
Returns the value of attribute expires_per_write.
-
#expiry_batch_size ⇒ Object
readonly
Returns the value of attribute expiry_batch_size.
-
#expiry_method ⇒ Object
readonly
Returns the value of attribute expiry_method.
-
#expiry_queue ⇒ Object
readonly
Returns the value of attribute expiry_queue.
-
#max_age ⇒ Object
readonly
Returns the value of attribute max_age.
-
#max_entries ⇒ Object
readonly
Returns the value of attribute max_entries.
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
Instance Attribute Details
#expires_per_write ⇒ Object (readonly)
Returns the value of attribute expires_per_write.
10 11 12 |
# File 'lib/solid_cache/store/expiry.rb', line 10 def expires_per_write @expires_per_write end |
#expiry_batch_size ⇒ Object (readonly)
Returns the value of attribute expiry_batch_size.
10 11 12 |
# File 'lib/solid_cache/store/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/store/expiry.rb', line 10 def expiry_method @expiry_method end |
#expiry_queue ⇒ Object (readonly)
Returns the value of attribute expiry_queue.
10 11 12 |
# File 'lib/solid_cache/store/expiry.rb', line 10 def expiry_queue @expiry_queue end |
#max_age ⇒ Object (readonly)
Returns the value of attribute max_age.
10 11 12 |
# File 'lib/solid_cache/store/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/store/expiry.rb', line 10 def max_entries @max_entries end |
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
10 11 12 |
# File 'lib/solid_cache/store/expiry.rb', line 10 def max_size @max_size end |
Instance Method Details
#initialize(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def initialize( = {}) super() @expiry_batch_size = .fetch(:expiry_batch_size, 100) @expiry_method = .fetch(:expiry_method, :thread) @expiry_queue = .fetch(:expiry_queue, :default) @expires_per_write = (1 / expiry_batch_size.to_f) * EXPIRY_MULTIPLIER @max_age = .fetch(:max_age, 2.weeks.to_i) @max_entries = .fetch(:max_entries, nil) @max_size = .fetch(:max_size, nil) raise ArgumentError, "Expiry method must be one of `:thread` or `:job`" unless [ :thread, :job ].include?(expiry_method) end |
#track_writes(count) ⇒ Object
25 26 27 |
# File 'lib/solid_cache/store/expiry.rb', line 25 def track_writes(count) expiry_batches(count).times { expire_later } end |