...

Source file src/github.com/gin-contrib/sessions/gorm/gorm.go

Documentation: github.com/gin-contrib/sessions/gorm

     1  package gorm
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/gin-contrib/sessions"
     7  	"github.com/wader/gormstore/v2"
     8  	"gorm.io/gorm"
     9  )
    10  
    11  type Store interface {
    12  	sessions.Store
    13  }
    14  
    15  func NewStore(d *gorm.DB, expiredSessionCleanup bool, keyPairs ...[]byte) Store {
    16  	s := gormstore.New(d, keyPairs...)
    17  	if expiredSessionCleanup {
    18  		quit := make(chan struct{})
    19  		go s.PeriodicCleanup(1*time.Hour, quit)
    20  	}
    21  	return &store{s}
    22  }
    23  
    24  type store struct {
    25  	*gormstore.Store
    26  }
    27  
    28  func (s *store) Options(options sessions.Options) {
    29  	s.Store.SessionOpts = options.ToGorillaOptions()
    30  }
    31  

View as plain text