Go to file
kekskurse 5ebd7f9537 List 2024-03-04 14:14:03 +01:00
.gitignore init 2024-03-04 11:20:04 +01:00
Readme.md note 2024-03-04 11:59:20 +01:00
error.go init 2024-03-04 11:20:04 +01:00
go.mod stuff 2024-03-04 12:39:10 +01:00
go.sum init 2024-03-04 11:20:04 +01:00
list.go List 2024-03-04 14:14:03 +01:00
state.go ram state for testing 2024-03-04 11:35:13 +01:00
state_test.go add list basics 2024-03-04 11:56:34 +01:00

Readme.md

State

From time to time i need some small state persistens like e.g. for a bot how count the numbers of messages with a special value. I want to store them somewhere to not cound double without thin king about it so i store a struct as json.

This pkg will provice Methodes to store (read and write) structs to the hdd.

Idear for later:

  • Store in S3 as well
  • Function for dealing with lists on store. Like add to list, chcik if exists in list and so on
  • IF deal with list store each element in a seperate key and a list of index in one. PRovide filtert lists that it not needed to keep the complet list in ram

Working with State

Write State to HDD

state, err := NewLocaleFilesystem("data/")
if err != nil {
    panic(err)
}

err = satate.StoreState("key", data)
if err != nil {
    panic(err)
}

Get State from HDD

state, err := NewLocaleFilesystem("data/")
if err != nil {
    panic(err)
}

err = satate.GetState("key", &data)
if err != nil {
    panic(err)
}