GetPersistent returns a single instance for the specific store
(dbPath, chunkPath string, f *Features)
| 40 | |
| 41 | // GetPersistent returns a single instance for the specific store |
| 42 | func GetPersistent(dbPath, chunkPath string, f *Features) (*Persistent, error) { |
| 43 | // write lock to create one |
| 44 | boltMapMx.Lock() |
| 45 | defer boltMapMx.Unlock() |
| 46 | if b, ok := boltMap[dbPath]; ok { |
| 47 | if !b.open { |
| 48 | err := b.connect() |
| 49 | if err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | } |
| 53 | return b, nil |
| 54 | } |
| 55 | |
| 56 | bb, err := newPersistent(dbPath, chunkPath, f) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | boltMap[dbPath] = bb |
| 61 | return boltMap[dbPath], nil |
| 62 | } |
| 63 | |
| 64 | type chunkInfo struct { |
| 65 | Path string |
searching dependent graphs…