Method: Mongo::Auth::CredentialCache.cache

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

.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



40
41
42
43
44
45
46
47
# File 'lib/mongo/auth/credential_cache.rb', line 40

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