Class: Mongo::Auth::Aws::CredentialsCache Private
- Inherits:
-
Object
- Object
- Mongo::Auth::Aws::CredentialsCache
- 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.
Class Method Summary collapse
-
.instance ⇒ CredentialsCache
private
Get or create the singleton instance of the cache.
Instance Method Summary collapse
-
#clear ⇒ Object
private
Clear the credentials from the cache.
-
#credentials ⇒ Aws::Credentials
private
Get the credentials from the cache.
-
#credentials=(credentials) ⇒ Object
private
Set the credentials in the cache.
-
#fetch ⇒ Aws::Credentials
private
Fetch the credentials from the cache or yield to get them if they are not in the cache or have expired.
-
#initialize ⇒ CredentialsCache
constructor
private
A new instance of CredentialsCache.
Constructor Details
#initialize ⇒ CredentialsCache
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.
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
.instance ⇒ CredentialsCache
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.
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
#clear ⇒ 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.
Clear the credentials from the cache.
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 |
#credentials ⇒ Aws::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.
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.
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 |
#fetch ⇒ Aws::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.
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 |