Class: SolidCache::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store_options: {}, database: nil, databases: nil, connects_to: nil, executor: nil, encrypt: false, encryption_context_properties: nil, size_estimate_samples: 10_000) ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
# File 'lib/solid_cache/configuration.rb', line 7

def initialize(store_options: {}, database: nil, databases: nil, connects_to: nil, executor: nil, encrypt: false, encryption_context_properties: nil, size_estimate_samples: 10_000)
  @store_options = store_options
  @size_estimate_samples = size_estimate_samples
  @executor = executor
  @encrypt = encrypt
  @encryption_context_properties = encryption_context_properties
  @encryption_context_properties ||= default_encryption_context_properties if encrypt?
  set_connects_to(database: database, databases: databases, connects_to: connects_to)
end

Instance Attribute Details

#connects_toObject (readonly)

Returns the value of attribute connects_to.



5
6
7
# File 'lib/solid_cache/configuration.rb', line 5

def connects_to
  @connects_to
end

#encryptObject (readonly)

Returns the value of attribute encrypt.



5
6
7
# File 'lib/solid_cache/configuration.rb', line 5

def encrypt
  @encrypt
end

#encryption_context_propertiesObject (readonly)

Returns the value of attribute encryption_context_properties.



5
6
7
# File 'lib/solid_cache/configuration.rb', line 5

def encryption_context_properties
  @encryption_context_properties
end

#executorObject (readonly)

Returns the value of attribute executor.



5
6
7
# File 'lib/solid_cache/configuration.rb', line 5

def executor
  @executor
end

#size_estimate_samplesObject (readonly)

Returns the value of attribute size_estimate_samples.



5
6
7
# File 'lib/solid_cache/configuration.rb', line 5

def size_estimate_samples
  @size_estimate_samples
end

#store_optionsObject (readonly)

Returns the value of attribute store_options.



5
6
7
# File 'lib/solid_cache/configuration.rb', line 5

def store_options
  @store_options
end

Instance Method Details

#encrypt?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/solid_cache/configuration.rb', line 25

def encrypt?
  encrypt.present?
end

#shard_keysObject



21
22
23
# File 'lib/solid_cache/configuration.rb', line 21

def shard_keys
  sharded? ? connects_to[:shards].keys : []
end

#sharded?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/solid_cache/configuration.rb', line 17

def sharded?
  connects_to && connects_to[:shards]
end