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.4.2"

Class Method Summary collapse

Class Method Details

.clear(raw_key) ⇒ Object



22
23
24
# File 'lib/cachext.rb', line 22

def self.clear raw_key
  Key(raw_key).clear
end

.clientObject



30
31
32
# File 'lib/cachext.rb', line 30

def self.client
  @client ||= Client.new config
end

.configObject



38
39
40
# File 'lib/cachext.rb', line 38

def self.config
  @config ||= Configuration.new
end

.config=(new_config) ⇒ Object



34
35
36
# File 'lib/cachext.rb', line 34

def self.config=(new_config)
  @config = new_config
end

.configure(&block) ⇒ Object



52
53
54
55
# File 'lib/cachext.rb', line 52

def self.configure &block
  @config = Configuration.setup(&block)
  @client = Client.new @config
end

.fetch(raw_key, overrides = {}, &block) ⇒ Object



18
19
20
# File 'lib/cachext.rb', line 18

def self.fetch raw_key, overrides = {}, &block
  client.fetch Key(raw_key), overrides, &block
end

.flushObject



42
43
44
45
46
# File 'lib/cachext.rb', line 42

def self.flush
  config.cache.clear
  keys = config.redis.keys("cachext:*")
  config.redis.del(*keys) if keys.length > 0
end

.Key(raw_key) ⇒ Object



14
15
16
# File 'lib/cachext.rb', line 14

def self.Key raw_key
  raw_key.is_a?(Key) ? raw_key : Key.new(raw_key)
end

.locked?(raw_key) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/cachext.rb', line 26

def self.locked? raw_key
  Key(raw_key).locked?
end

.multi(klass, ids, options = {}, &block) ⇒ Object



48
49
50
# File 'lib/cachext.rb', line 48

def self.multi klass, ids, options = {}, &block
  Multi.new(config, klass, options).fetch ids, &block
end