Class: Mongo::Auth::Aws::CredentialsCache Private

Inherits:
Object
  • Object
show all
Defined in:
build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb

Overview

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

Thread safe cache to store AWS credentials.

Since:

  • 2.0.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCredentialsCache

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.

Returns a new instance of CredentialsCache.

Since:

  • 2.0.0



32
33
34
35
# File 'build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb', line 32

def initialize
  @lock = Mutex.new
  @credentials = nil
end

Class Method Details

.instanceCredentialsCache

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.

Get or create the singleton instance of the cache.

Returns:

Since:

  • 2.0.0



28
29
30
# File 'build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb', line 28

def self.instance
  @instance ||= new
end

Instance Method Details

#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.

Clear the credentials from the cache.

Since:

  • 2.0.0



67
68
69
70
71
# File 'build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb', line 67

def clear
  @lock.synchronize do
    @credentials = nil
  end
end

#credentialsAws::Credentials

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.

Get the credentials from the cache.

Returns:

Since:

  • 2.0.0



49
50
51
52
53
# File 'build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb', line 49

def credentials
  @lock.synchronize do
    @credentials
  end
end

#credentials=(credentials) ⇒ 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.

Set the credentials in the cache.

Parameters:

Since:

  • 2.0.0



40
41
42
43
44
# File 'build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb', line 40

def credentials=(credentials)
  @lock.synchronize do
    @credentials = credentials
  end
end

#fetchAws::Credentials

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.

Fetch the credentials from the cache or yield to get them if they are not in the cache or have expired.

Returns:

Since:

  • 2.0.0



59
60
61
62
63
64
# File 'build/ruby-driver-v2.19/lib/mongo/auth/aws/credentials_cache.rb', line 59

def fetch
  @lock.synchronize do
    @credentials = yield if @credentials.nil? || @credentials.expired?
    @credentials
  end
end