func (obj *csrfService) Set(key string, val []byte, ttl time.Duration) error {
	v, _ := obj.Get(key)
	if v != nil {
		return errors.New(errors.InvalidStatus, errors.Resend, g.Trans().TranslateEN("DuplicateCSRF"))
	}
	if key == "" || val == nil {
		return nil
	}

	t := time.Now().Add(ttl)
	csrfs := []models.CSRF{
		{
			Key:        key,
			Value:      string(val),
			ExpireDate: t,
		},
	}
	_, err := db.Insert(models.CSRFName).Rows(csrfs).Executor().Exec()
	if err != nil {
		return errors.New(errors.UnexpectedStatus, errors.Report, g.Trans().TranslateEN("CreationCSRFFailed"))
	}

	return nil
}
// Set stores the given value for the given key along with a
// time-to-live expiration value, 0 means live for ever
// Empty key or value will be ignored without an error.
Set stores the given value for the given key along with a
time-to-live expiration value, 0 means live for ever
Empty key or value will be ignored without an error.
// Set stores the given value for the given key along with a // time - to - live expiration value 0 means live for ever // Empty key or value will be ignored without an error .
func (obj *csrfService) Set(key string, val []byte, ttl time.Duration) error {
	v, _ := obj.Get(key)
	if v != nil {
		return errors.New(errors.InvalidStatus, errors.Resend, g.Trans().TranslateEN("DuplicateCSRF"))
	}
	if key == "" || val == nil {
		return nil
	}
	t := time.Now().Add(ttl)
	csrfs := []models.CSRF{
		{
			Key:        key,
			Value:      string(val),
			ExpireDate: t,
		},
	}
	_, err := db.Insert(models.CSRFName).Rows(csrfs).Executor().Exec()
	if err != nil {
		return errors.New(errors.UnexpectedStatus, errors.Report, g.Trans().TranslateEN("CreationCSRFFailed"))
	}
	return nil
}
func ( obj * csrfService ) Set ( key string , val [ ] byte , ttl time . Duration ) error { v , _ := obj . Get ( key ) if v != nil { return errors . New ( errors . InvalidStatus , errors . Resend , g . Trans ( ) . TranslateEN ( " " ) ) } if key == " " || val == nil { return nil } t := time . Now ( ) . Add ( ttl ) csrfs := [ ] models . CSRF { { Key : key , Value : string ( val ) , ExpireDate : t , } , } _ , err := db . Insert ( models . CSRFName ) . Rows ( csrfs ) . Executor ( ) . Exec ( ) if err != nil { return errors . New ( errors . UnexpectedStatus , errors . Report , g . Trans ( ) . TranslateEN ( " " ) ) } return nil }
Set stores the given value for the given key along with a
time-to-live expiration value, 0 means live for ever
Empty key or value will be ignored without an error.
Set stores the given value for the given key along with a time - to - live expiration value 0 means live for ever Empty key or value will be ignored without an error .