Skip to content

Latest commit

 

History

History

mysqlstore

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

MySQL Store for Captchas

Firstly, you need to create a captcha table, migration.

$ go get clevergo.tech/captchas/stores/mysqlstore
import (
	"clevergo.tech/captchas/stores/dbstore"
	"clevergo.tech/captchas/stores/mysqlstore"
	_ "github.com/go-sql-driver/mysql"
)
db, err := sql.Open("mysql", "")
if err != nil {
	// ...
}
store := mysqlstore.New(
	db,
	dbstore.Expiration(10*time.Minute), // captcha expiration, optional.
	dbstore.GCInterval(time.Minute), // garbage collection interval to delete expired captcha, optional.
	dbstore.TableName("captchas"), // table name, optional.
	dbstore.Category("default"), // category, optional.
)