Skip to content
montsamu edited this page Sep 13, 2010 · 4 revisions

The “persist” nonsense occupies a directory and stores files by id name. Data inside is key1=value1&key2=value2 and so on. No query or index, just New, Get, and Del.

Use:

import (
    "persist";
)

var my_persist_service = persist.NewPersistService("mydir"); // mydir must exist and be writable

my_model := my_persist_service.New("myid", map[string]string {"some":"data", "to":"store"}); // mydir/myid now exists

another_model := my_persist_service.Get("anotherid"); // model is Id string and Data map[string]string

my_persist_service.Del(bad_model.Id); // bye bye bad model

That’s pretty much it.

VERY BAD THINGS: bad id passed functions may let you destroy your filesystem or crash your program.

Clone this wiki locally