code: func NewSQLStore(log logger.Logger, driver, source string, limits *StoreLimits, options ...SQLStoreOption) (*SQLStore, error) {
  	initSQLStmts.Do(func() { initSQLStmtsTable(driver) })
  	db, err := sql.Open(driver, source)
  	if err != nil {
  		return nil, err
  	}
  	if err := db.Ping(); err != nil {
  		db.Close()
  		return nil, err
  	}
  	// Start with empty options
  	opts := DefaultSQLStoreOptions()
  	// And apply whatever is given to us as options.
  	for _, opt := range options {
  		if err := opt(opts); err != nil {
  			return nil, err
  		}
  	}
  	db.SetMaxOpenConns(opts.MaxOpenConns)
  	s := &SQLStore{
  		opts:          opts,
  		db:            db,
  		doneCh:        make(chan struct{}),
  		preparedStmts: make([]*sql.Stmt, 0, len(sqlStmts)),
  	}
  	if err := s.init(TypeSQL, log, limits); err != nil {
  		s.Close()
  		return nil, err
  	}
  	if err := s.createPreparedStmts(); err != nil {
  		s.Close()
  		return nil, err
  	}
  	s.Lock()
  	s.wg.Add(1)
  	go s.timeTick()
  	if !s.opts.NoCaching {
  		s.wg.Add(1)
  		s.ssFlusher = &subStoresFlusher{
  			stores:   make(map[*SQLSubStore]struct{}),
  			signalCh: make(chan struct{}, 1),
  		}
  		go s.subStoresFlusher()
  	}
  	s.Unlock()
  	return s, nil
  }
docs: ////////////////////////////////////////////////////////////////////////////
  // SQLStore methods
  ////////////////////////////////////////////////////////////////////////////
  // NewSQLStore returns a factory for stores held in memory.
  // If not limits are provided, the store will be created with
  // DefaultStoreLimits.