MCPcopy Index your code
hub / github.com/FloatTech/AnimeAPI / NewPool

Function NewPool

setu/pool.go:42–61  ·  view source on GitHub ↗

NewPool 新的缓存池

(folder string, rolimg func(string) (string, error), getdat func(string) ([]byte, error), timeout time.Duration)

Source from the content-addressed store, hash-verified

40
41// NewPool 新的缓存池
42func NewPool(folder string, rolimg func(string) (string, error), getdat func(string) ([]byte, error), timeout time.Duration) (*Pool, error) {
43 if folder == "" {
44 return nil, ErrNilFolder
45 }
46 if file.IsNotExist(folder) {
47 err := os.MkdirAll(folder, 0755)
48 if err != nil {
49 return nil, err
50 }
51 }
52 if folder[len(folder)-1] != '/' {
53 folder += "/"
54 }
55 return &Pool{
56 folder: folder,
57 rolimg: rolimg,
58 getdat: getdat,
59 timeout: timeout,
60 }, nil
61}
62
63// Roll 从缓存池随机挑一张
64func (p *Pool) Roll(typ string) (string, error) {

Callers 2

default.goFile · 0.85
TestPoolFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestPoolFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…