func NewJsonSyncStore(ctx context.Context, fn string, data Value, tickSave *time.Ticker, saveOnStore bool) (*SyncStore, error) {
	js := &jsonStore{
		mu:          &sync.Mutex{},
		ctx:         ctx,
		store:       &atomic.Value{},
		fn:          fn,
		saveOnStore: saveOnStore,
	}
	err := js.open(data)
	if err != nil {
		return nil, err
	}
	sc := NewSyncStore(js)
	if tickSave != nil {
		sc.Go(func(dn <-chan struct{}, st Store) {
			for {
				select {
				case <-dn:
					return
				case <-tickSave.C:
					st.Save()
				}
			}
		})
	}
	return sc, nil
}
// data must contain initial value for store it in json file (if not exists)
data must contain initial value for store it in json file (if not exists)
// data must contain initial value for store it in json file ( if not exists )
func NewJsonSyncStore(ctx context.Context, fn string, data Value, tickSave *time.Ticker, saveOnStore bool) (*SyncStore, error) {
	js := &jsonStore{
		mu:          &sync.Mutex{},
		ctx:         ctx,
		store:       &atomic.Value{},
		fn:          fn,
		saveOnStore: saveOnStore,
	}
	err := js.open(data)
	if err != nil {
		return nil, err
	}
	sc := NewSyncStore(js)
	if tickSave != nil {
		sc.Go(func(dn <-chan struct{}, st Store) {
			for {
				select {
				case <-dn:
					return
				case <-tickSave.C:
					st.Save()
				}
			}
		})
	}
	return sc, nil
}
func NewJsonSyncStore ( ctx context . Context , fn string , data Value , tickSave * time . Ticker , saveOnStore bool ) ( * SyncStore , error ) { js := & jsonStore { mu : & sync . Mutex { } , ctx : ctx , store : & atomic . Value { } , fn : fn , saveOnStore : saveOnStore , } err := js . open ( data ) if err != nil { return nil , err } sc := NewSyncStore ( js ) if tickSave != nil { sc . Go ( func ( dn <- chan struct { } , st Store ) { for { select { case <- dn : return case <- tickSave . C : st . Save ( ) } } } ) } return sc , nil }
data must contain initial value for store it in json file (if not exists)
data must contain initial value for store it in json file ( if not exists )