Documentation ¶
Index ¶
- Constants
- Variables
- func ClearUserDatabase(sessionToken string)
- func LoadResource(bucketName, idToLoad string) []byte
- func SaveGenericResource(bucketName, idToSave string, dataToSave []byte)
- func SaveResource(r Resource)
- func ShutdownDBM()
- func StartupDBM(userSession string) error
- type DatabaseManager
- type Resource
Constants ¶
View Source
const ( // Buckets PAGE_DATA = "PageData" CALENDAR = "Calendar" USER_DATA = "UserData" LEADERBOARDS = "Leaderboards" PUZZLES = "Puzzles" // Sub Buckets USER_INPUTS = "UserInputs" USER_PAGES = "UserPages" // Other GENERIC_USER = "GenericUser" )
Variables ¶
View Source
var (
UserCacheDir, _ = os.UserCacheDir()
CacheDir = path.Join(UserCacheDir, "aocgo")
CacheFile = path.Join(CacheDir, "%v.db")
InputCacheDir = path.Join(CacheDir, "inputs")
GeneralCacheDB = fmt.Sprintf(CacheFile, GENERIC_USER)
)
Functions ¶
func ClearUserDatabase ¶
func ClearUserDatabase(sessionToken string)
Clear database file for a certain user
func LoadResource ¶
Load resource from database by ID
func SaveGenericResource ¶
Save resource to database
func SaveResource ¶
func SaveResource(r Resource)
func StartupDBM ¶
Create and initialize master database manager, taking in a valid AoC user session token
Types ¶
type DatabaseManager ¶
type DatabaseManager struct {
// contains filtered or unexported fields
}
Database Manager
func (*DatabaseManager) Shutdown ¶
func (dbm *DatabaseManager) Shutdown()
Ensure database is properly closed
type Resource ¶
type Resource interface { GetID() string // ID is used as key for storage GetBucketName() string // Returns the name of the bucket the resource is stored in MarshalData() ([]byte, error) // Returns the resources data in a savable format SaveResource() }
Interface for storable resource
Click to show internal directories.
Click to hide internal directories.