Class: ArCache::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ar_cache/configuration.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_lock=(value) ⇒ Object (writeonly)

Sets the attribute cache_lock

Parameters:

  • value

    the value to set the attribute cache_lock to.



6
7
8
# File 'lib/ar_cache/configuration.rb', line 6

def cache_lock=(value)
  @cache_lock = value
end

.cache_storeObject

Returns the value of attribute cache_store.



7
8
9
# File 'lib/ar_cache/configuration.rb', line 7

def cache_store
  @cache_store
end

.disabledObject

Returns the value of attribute disabled.



8
9
10
# File 'lib/ar_cache/configuration.rb', line 8

def disabled
  @disabled
end

.expires_inObject

Returns the value of attribute expires_in.



8
9
10
# File 'lib/ar_cache/configuration.rb', line 8

def expires_in
  @expires_in
end

.lock_statementObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ar_cache/configuration.rb', line 50

def lock_statement
  @lock_statement ||= case ::ActiveRecord::Base.connection.class.name
                      when 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
                        'FOR SHARE'
                      when 'ActiveRecord::ConnectionAdapters::Mysql2Adapter'
                        'LOCK IN SHARE MODE'
                      when 'ActiveRecord::ConnectionAdapters::SQLite3Adapter'
                        raise "SQLite3 don't support lock statement, please use cache lock."
                      else
                        raise "Arcache can't identify database, please defined lock statement or use cache lock"
                      end
end

.select_disabledObject

Returns the value of attribute select_disabled.



8
9
10
# File 'lib/ar_cache/configuration.rb', line 8

def select_disabled
  @select_disabled
end

.tables_optionsObject

Returns the value of attribute tables_options.



7
8
9
# File 'lib/ar_cache/configuration.rb', line 7

def tables_options
  @tables_options
end

Class Method Details

.cache_lock?Boolean

Returns:

  • (Boolean)


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

def cache_lock?
  @cache_lock
end

.configureObject



10
11
12
# File 'lib/ar_cache/configuration.rb', line 10

def configure
  block_given? ? yield(self) : self
end

.get_table_options(name) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/ar_cache/configuration.rb', line 42

def get_table_options(name)
  options = tables_options[name.to_sym] || {}
  options[:disabled] = disabled unless options.key?(:disabled)
  options[:select_disabled] = select_disabled unless options.key?(:select_disabled)
  options[:unique_indexes] = Array(options[:unique_indexes]).map { |index| Array(index).map(&:to_s).uniq }.uniq
  options
end

.memcached?Boolean

Returns:

  • (Boolean)


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

def memcached?
  @memcached
end

.redis?Boolean

Returns:

  • (Boolean)


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

def redis?
  @redis
end