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.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def expires_per_write @expires_per_write end |
#expiry_batch_size ⇒ Object (readonly)
Returns the value of attribute expiry_batch_size.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def expiry_batch_size @expiry_batch_size end |
#expiry_method ⇒ Object (readonly)
Returns the value of attribute expiry_method.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def expiry_method @expiry_method end |
#expiry_queue ⇒ Object (readonly)
Returns the value of attribute expiry_queue.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def expiry_queue @expiry_queue end |
#max_age ⇒ Object (readonly)
Returns the value of attribute max_age.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def max_age @max_age end |
#max_entries ⇒ Object (readonly)
Returns the value of attribute max_entries.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def max_entries @max_entries end |
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
12 13 14 |
# File 'lib/solid_cache/store/expiry.rb', line 12 def max_size @max_size end |
Instance Method Details
#initialize(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/solid_cache/store/expiry.rb', line 14 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
27 28 29 |
# File 'lib/solid_cache/store/expiry.rb', line 27 def track_writes(count) expiry_batches(count).times { expire_later } end |