Giter Club home page Giter Club logo

dynastore's Introduction

dynastore

AWS DynamoDB store for Gorilla Toolkit using AWS library. Includes support for DynamoDB's TTL feature.

Uses the official AWS library, github.com/aws/aws-sdk-go/aws

Installation

go get github.com/savaki/dynastore/...

Environment Variables

dynastore uses the common AWS environment variables:

  • AWS_DEFAULT_REGION or AWS_REGION
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

dynastore will also use AWS roles if they are available. In that case, only AWS_DEFAULT_REGION or AWS_REGION need be set.

Alternately, AWS settings can be specified using Options:

  • dynastore.AWSConfig(*aws.Config)
  • dynastore.DynamoDB(*dynamodb.DynamoDB)

Tables

dynastore provides a utility to create/delete the dynamodb table.

Create Table

dynastore -table your-table-name -read 5 -write 5 

Delete Table

Use the -delete flag to indicate the tables should be deleted instead.

dynastore -table your-table-name -delete 

Example

// Create Store
store, err := dynastore.New(dynastore.Path("/"), dynastore.HTTPOnly())
if err != nil {
  log.Fatalln(err)
}

// Get Session
session, err := store.Get(req, "session-key")
if err != nil {
  log.Fatalln(err)
}

// Add a Value
session.Values["hello"] = "world"

// Save Session
err := session.Save(req, w)
if err != nil {
  log.Fatalln(err)
}

// Delete Session
session.Options.MaxAge = -1
err := session.Save(req, w)
if err != nil {
  log.Fatalln(err)
}

dynastore's People

Contributors

savaki avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.