Module: ArCache
- Defined in:
- lib/ar_cache/log_subscriber.rb,
lib/ar_cache.rb,
lib/ar_cache/query.rb,
lib/ar_cache/table.rb,
lib/ar_cache/marshal.rb,
lib/ar_cache/version.rb,
lib/ar_cache/mock_table.rb,
lib/ar_cache/where_clause.rb,
lib/ar_cache/configuration.rb,
lib/ar_cache/active_record/core.rb,
lib/ar_cache/active_record/relation.rb,
lib/ar_cache/active_record/insert_all.rb,
lib/ar_cache/active_record/persistence.rb,
lib/ar_cache/active_record/model_schema.rb,
lib/generators/ar_cache/install_generator.rb,
lib/ar_cache/active_record/associations/association.rb,
lib/ar_cache/active_record/associations/singular_association.rb,
lib/ar_cache/active_record/associations/has_one_through_association.rb,
lib/ar_cache/active_record/connection_adapters/abstract/transaction.rb,
lib/ar_cache/active_record/connection_adapters/abstract/database_statements.rb
Overview
Defined Under Namespace
Modules: ActiveRecord, Generators, Marshal
Classes: Configuration, LogSubscriber, MockTable, Query, Table, WhereClause
Constant Summary
collapse
- PLACEHOLDER =
''
- VERSION =
'2.2.0'
Class Method Summary
collapse
Class Method Details
.cache_reflection?(reflection) ⇒ Boolean
58
59
60
61
62
63
64
65
|
# File 'lib/ar_cache.rb', line 58
def cache_reflection?(reflection)
@cache_reflection.fetch(reflection) do
Thread.current[:ar_cache_reflection] = true
@cache_reflection[reflection] = yield
ensure
Thread.current[:ar_cache_reflection] = false
end
end
|
.dump_attributes(attributes) ⇒ Object
67
68
69
|
# File 'lib/ar_cache.rb', line 67
def dump_attributes(attributes)
memcached? || redis? ? Oj.dump(attributes) : attributes
end
|
.load_attributes(attributes) ⇒ Object
71
72
73
|
# File 'lib/ar_cache.rb', line 71
def load_attributes(attributes)
memcached? || redis? ? Oj.load(attributes) : attributes
end
|
.lock_key(key) ⇒ Object
75
76
77
|
# File 'lib/ar_cache.rb', line 75
def lock_key(key)
ArCache.write(key, PLACEHOLDER, raw: true, expires_in: 1.hour)
end
|
.skip_cache ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/ar_cache.rb', line 32
def skip_cache
return yield if skip_cache?
begin
Thread.current[:ar_cache_skip_cache] = true
yield
ensure
Thread.current[:ar_cache_skip_cache] = false
end
end
|
.skip_cache? ⇒ Boolean
28
29
30
|
# File 'lib/ar_cache.rb', line 28
def skip_cache?
Thread.current[:ar_cache_skip_cache]
end
|
.skip_expire ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ar_cache.rb', line 47
def skip_expire
return yield if skip_expire?
begin
Thread.current[:ar_cache_skip_expire] = true
yield
ensure
Thread.current[:ar_cache_skip_expire] = false
end
end
|
.skip_expire? ⇒ Boolean
43
44
45
|
# File 'lib/ar_cache.rb', line 43
def skip_expire?
Thread.current[:ar_cache_skip_expire]
end
|