Class: PgParty::Cache
- Inherits:
-
Object
- Object
- PgParty::Cache
- Defined in:
- lib/pg_party/cache.rb
Constant Summary collapse
- LOCK =
Mutex.new
Class Method Summary collapse
- .clear! ⇒ Object
- .fetch_model(key, child_table, &block) ⇒ Object
- .fetch_partitions(key, &block) ⇒ Object
Class Method Details
.clear! ⇒ Object
10 11 12 13 14 |
# File 'lib/pg_party/cache.rb', line 10 def clear! LOCK.synchronize { store.clear } nil end |
.fetch_model(key, child_table, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/pg_party/cache.rb', line 16 def fetch_model(key, child_table, &block) LOCK.synchronize do store[key][:models][child_table.to_sym] ||= block.call end end |
.fetch_partitions(key, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/pg_party/cache.rb', line 22 def fetch_partitions(key, &block) LOCK.synchronize do store[key][:partitions] ||= block.call end end |