Module: Cachext
- Defined in:
- lib/cachext.rb,
lib/cachext/key.rb,
lib/cachext/multi.rb,
lib/cachext/client.rb,
lib/cachext/breaker.rb,
lib/cachext/options.rb,
lib/cachext/version.rb,
lib/cachext/features.rb,
lib/cachext/configuration.rb,
lib/cachext/features/lock.rb,
lib/cachext/missing_record.rb,
lib/cachext/features/backup.rb,
lib/cachext/features/default.rb,
lib/cachext/features/debug_logging.rb,
lib/cachext/features/circuit_breaker.rb
Defined Under Namespace
Modules: Features
Classes: Breaker, Client, Configuration, Key, MissingRecord, Multi, Options
Constant Summary
collapse
- VERSION =
"0.5.0"
Class Method Summary
collapse
Class Method Details
.clear(raw_key) ⇒ Object
21
22
23
|
# File 'lib/cachext.rb', line 21
def self.clear raw_key
Key(raw_key).clear
end
|
.client ⇒ Object
29
30
31
|
# File 'lib/cachext.rb', line 29
def self.client
@client ||= Client.new config
end
|
.config ⇒ Object
37
38
39
|
# File 'lib/cachext.rb', line 37
def self.config
@config ||= Configuration.new
end
|
.config=(new_config) ⇒ Object
33
34
35
|
# File 'lib/cachext.rb', line 33
def self.config=(new_config)
@config = new_config
end
|
51
52
53
54
55
|
# File 'lib/cachext.rb', line 51
def self.configure &block
@config_block = block
@config = Configuration.setup(&block)
@client = Client.new @config
end
|
.fetch(raw_key, overrides = {}, &block) ⇒ Object
17
18
19
|
# File 'lib/cachext.rb', line 17
def self.fetch raw_key, overrides = {}, &block
client.fetch Key(raw_key), overrides, &block
end
|
.flush ⇒ Object
41
42
43
44
45
|
# File 'lib/cachext.rb', line 41
def self.flush
config.cache.clear
keys = config.redis.keys("cachext:*")
config.redis.del(*keys) if keys.length > 0
end
|
.forked! ⇒ Object
57
58
59
|
# File 'lib/cachext.rb', line 57
def self.forked!
configure(&@config_block)
end
|
.Key(raw_key) ⇒ Object
13
14
15
|
# File 'lib/cachext.rb', line 13
def self.Key raw_key
raw_key.is_a?(Key) ? raw_key : Key.new(raw_key)
end
|
.locked?(raw_key) ⇒ Boolean
25
26
27
|
# File 'lib/cachext.rb', line 25
def self.locked? raw_key
Key(raw_key).locked?
end
|
.multi(klass, ids, options = {}, &block) ⇒ Object
47
48
49
|
# File 'lib/cachext.rb', line 47
def self.multi klass, ids, options = {}, &block
Multi.new(config, klass, options).fetch ids, &block
end
|