initial commit
This commit is contained in:
35
cachedb/funcs.go
Normal file
35
cachedb/funcs.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package cachedb
|
||||
|
||||
import (
|
||||
`os`
|
||||
`path/filepath`
|
||||
|
||||
`r00t2.io/sysutils/paths`
|
||||
)
|
||||
|
||||
/*
|
||||
NewCache returns a Cache from path to SQLite file `db` (or ":memory:" for an in-memory one).
|
||||
|
||||
It will be created if it doesn't exist for persistent caches.
|
||||
*/
|
||||
func NewCache(db string) (c *Cache, err error) {
|
||||
|
||||
var exists bool
|
||||
|
||||
switch db {
|
||||
case ":memory:":
|
||||
default:
|
||||
if exists, err = paths.RealPathExists(&db); err != nil {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
if err = os.MkdirAll(filepath.Dir(db), 0700); err != nil {
|
||||
return
|
||||
}
|
||||
if err = os.WriteFile()
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user