Class: Mongo::Auth::Aws::CredentialsCache Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/mongo/auth/aws/credentials_cache.rb |
Overview
Thread safe cache to store AWS credentials.
Class Method Summary
-
.instance ⇒ CredentialsCache
Internal use only
Get or create the singleton instance of the cache.
- .new ⇒ CredentialsCache constructor Internal use only
Instance Attribute Summary
-
#credentials ⇒ Aws::Credentials
rw
Internal use only
Get the credentials from the cache.
-
#credentials=(credentials)
rw
Internal use only
Set the credentials in the cache.
Instance Method Summary
-
#clear
Internal use only
Clear the credentials from the cache.
-
#fetch ⇒ Aws::Credentials
Internal use only
Fetch the credentials from the cache or yield to get them if they are not in the cache or have expired.
Class Method Details
.instance ⇒ CredentialsCache
Get or create the singleton instance of the cache.
# File 'lib/mongo/auth/aws/credentials_cache.rb', line 28
def self.instance @instance ||= new end
Instance Attribute Details
#credentials ⇒ Aws::Credentials (rw)
Get the credentials from the cache.
# File 'lib/mongo/auth/aws/credentials_cache.rb', line 49
def credentials @lock.synchronize do @credentials end end
#credentials=(credentials) (rw)
Set the credentials in the cache.
# File 'lib/mongo/auth/aws/credentials_cache.rb', line 40
def credentials=(credentials) @lock.synchronize do @credentials = credentials end end
Instance Method Details
#clear
Clear the credentials from the cache.
# File 'lib/mongo/auth/aws/credentials_cache.rb', line 67
def clear @lock.synchronize do @credentials = nil end end
#fetch ⇒ Aws::Credentials
Fetch the credentials from the cache or yield to get them if they are not in the cache or have expired.
# File 'lib/mongo/auth/aws/credentials_cache.rb', line 59
def fetch @lock.synchronize do @credentials = yield if @credentials.nil? || @credentials.expired? @credentials end end