Module: Mongo::Auth::CredentialCache Private

Defined in:
lib/mongo/auth/credential_cache.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Cache store for computed SCRAM credentials.

Since:

  • 2.0.0

Constant Summary collapse

MUTEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Mutex.new

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.storeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



26
27
28
# File 'lib/mongo/auth/credential_cache.rb', line 26

def store
  @store
end

Class Method Details

.cache(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



45
46
47
48
49
50
51
52
# File 'lib/mongo/auth/credential_cache.rb', line 45

module_function def cache(key)
  value = get(key)
  if value.nil?
    value = yield
    set(key, value)
  end
  value
end

.clearObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



54
55
56
57
58
# File 'lib/mongo/auth/credential_cache.rb', line 54

module_function def clear
  MUTEX.synchronize do
    @store = {}
  end
end

.get(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



31
32
33
34
35
36
# File 'lib/mongo/auth/credential_cache.rb', line 31

module_function def get(key)
  MUTEX.synchronize do
    @store ||= {}
    @store[key]
  end
end

.set(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



38
39
40
41
42
43
# File 'lib/mongo/auth/credential_cache.rb', line 38

module_function def set(key, value)
  MUTEX.synchronize do
    @store ||= {}
    @store[key] = value
  end
end