AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Module: Aws::SessionStore::DynamoDB::Table

Defined in:
lib/aws/session_store/dynamo_db/table.rb

Overview

This class provides a way to create and delete a session table.

Class Method Summary collapse

Class Method Details

.create_table(options = {}) ⇒ Object

Creates a session table.

Options Hash (options):

  • :table_name (String) — default: "Sessions"

    Name of the session table.

  • :table_key (String) — default: "id"

    The hash key of the sesison table.

  • :consistent_read (Boolean) — default: true

    If true, a strongly consistent read is used. If false, an eventually consistent read is used.

  • :read_capacity (Integer) — default: 10

    The maximum number of strongly consistent reads consumed per second before DynamoDB raises a ThrottlingException. See AWS DynamoDB documentation for table read_capacity for more information on this setting.

  • :write_capacity (Integer) — default: 5

    The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation for table write_capacity for more information on this setting.

  • :dynamo_db_client (DynamoDB Client) — default: Aws::DynamoDB::Client

    DynamoDB client used to perform database operations inside of middleware application.

  • :raise_errors (Boolean) — default: false

    If true, all errors are raised up the stack when default ErrorHandler. If false, Only specified errors are raised up the stack when default ErrorHandler is used.

  • :error_handler (Error Handler) — default: DefaultErrorHandler

    An error handling object that handles all exceptions thrown during execution of the AWS DynamoDB Session Store Rack Middleware. For more information see the Handling Errors Section.

  • :max_age (Integer) — default: nil

    Maximum number of seconds earlier from the current time that a session was created.

  • :max_stale (Integer) — default: nil

    Maximum number of seconds before current time that session was last accessed.

  • :secret_key (String) — default: nil

    Secret key for HMAC encription.

  • :enable_locking (Integer) — default: false

    If true, a pessimistic locking strategy will be implemented for all session accesses. If false, no locking strategy will be implemented for all session accesses.

  • :lock_expiry_time (Integer) — default: 500

    Time in milliseconds after which lock expires on session.

  • :lock_retry_delay (Integer) — default: 500

    Time in milleseconds to wait before retrying to obtain lock once an attempt to obtain lock has been made and has failed.

  • :lock_max_wait_time (Integer) — default: 500

    Maximum time in seconds to wait to acquire lock before giving up.

  • :secret_key (String) — default: SecureRandom.hex(64)

    Secret key for HMAC encription.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/aws/session_store/dynamo_db/table.rb', line 24

def create_table(options = {})
  config = load_config(options)
  ddb_options = properties(config.table_name, config.table_key).merge(
      throughput(config.read_capacity, config.write_capacity)
    )
  config.dynamo_db_client.create_table(ddb_options)
  logger << "Table #{config.table_name} created, waiting for activation...\n"
  block_until_created(config)
  logger << "Table #{config.table_name} is now ready to use.\n"
rescue Aws::DynamoDB::Errors::ResourceInUseException
  logger << "Table #{config.table_name} already exists, skipping creation.\n"
end

.delete_table(options = {}) ⇒ Object

Deletes a session table.

Options Hash (options):

  • :table_name (String) — default: "Sessions"

    Name of the session table.

  • :table_key (String) — default: "id"

    The hash key of the sesison table.

  • :consistent_read (Boolean) — default: true

    If true, a strongly consistent read is used. If false, an eventually consistent read is used.

  • :read_capacity (Integer) — default: 10

    The maximum number of strongly consistent reads consumed per second before DynamoDB raises a ThrottlingException. See AWS DynamoDB documentation for table read_capacity for more information on this setting.

  • :write_capacity (Integer) — default: 5

    The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation for table write_capacity for more information on this setting.

  • :dynamo_db_client (DynamoDB Client) — default: Aws::DynamoDB::Client

    DynamoDB client used to perform database operations inside of middleware application.

  • :raise_errors (Boolean) — default: false

    If true, all errors are raised up the stack when default ErrorHandler. If false, Only specified errors are raised up the stack when default ErrorHandler is used.

  • :error_handler (Error Handler) — default: DefaultErrorHandler

    An error handling object that handles all exceptions thrown during execution of the AWS DynamoDB Session Store Rack Middleware. For more information see the Handling Errors Section.

  • :max_age (Integer) — default: nil

    Maximum number of seconds earlier from the current time that a session was created.

  • :max_stale (Integer) — default: nil

    Maximum number of seconds before current time that session was last accessed.

  • :secret_key (String) — default: nil

    Secret key for HMAC encription.

  • :enable_locking (Integer) — default: false

    If true, a pessimistic locking strategy will be implemented for all session accesses. If false, no locking strategy will be implemented for all session accesses.

  • :lock_expiry_time (Integer) — default: 500

    Time in milliseconds after which lock expires on session.

  • :lock_retry_delay (Integer) — default: 500

    Time in milleseconds to wait before retrying to obtain lock once an attempt to obtain lock has been made and has failed.

  • :lock_max_wait_time (Integer) — default: 500

    Maximum time in seconds to wait to acquire lock before giving up.

  • :secret_key (String) — default: SecureRandom.hex(64)

    Secret key for HMAC encription.



39
40
41
42
# File 'lib/aws/session_store/dynamo_db/table.rb', line 39

def delete_table(options = {})
  config = load_config(options)
  config.dynamo_db_client.delete_table(:table_name => config.table_name)
end