{"modulePath":"github.com/MG-RAST/Shock","version":"v0.9.30-0.20260305221922-9419e651c08a","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cache\n\n## Variables\n\n```go\nvar CacheMap map[string]*Item\n```\nCacheMap store UUID, size, type, atime and ctime in separate (sorted) table for access by fileReaper\n\n```go\nvar CacheMapLock = sync.RWMutex{}\n```\nCacheMapLock lock write access to the CacheMap\n\n## Functions\n\n```go\nfunc Add(ID string, size int64)\n```\nAdd an entry to the Cache for ID\n\n```go\nfunc InitCacheReaper()\n```\nInitCacheReaper initializes the cache reaper if TTL is configured\n\n```go\nfunc Initialize() (err error)\n```\nInitialize find all \\*.data files for nodes and populate cache only call if global --is-cache=true\n\n```go\nfunc ParseTTL(ttlStr string) time.Duration\n```\nParseTTL parses a TTL string like \"24H\", \"7D\", \"30M\" into a time.Duration\n\n```go\nfunc Path2uuid(fpath string) string\n```\nPath2uuid extract uuid from path\n\n```go\nfunc Remove(ID string) (err error)\n```\nRemove an entry to the CacheMap and the file on disk\n\n```go\nfunc Touch(ID string)\n```\nTouch update cache LRU info\n\n## Types\n\n```go\ntype CacheCleanup struct {\n\t// contains filtered or unexported fields\n}\n```\nCacheCleanup handles periodic cleanup of expired cache items\n\n```go\nvar (\n\tCacheReaper *CacheCleanup\n\tTTLRegex    = regexp.MustCompile(`^(\\d+)(M|H|D)$`)\n)\n```\n\n```go\nfunc (cr *CacheCleanup) Handle()\n```\nHandle runs the cache cleanup loop\n\n```go\ntype Item struct {\n\tUUID      string    `bson:\"uuid\" json:\"uuid\" `                   // e.g. node UUID\n\tAccess    time.Time `bson:\"last_accessed\" json:\"last_accessed\" ` // e.g. access time\n\tType      string    `bson:\"type\" json:\"type\"`\n\tSize      int64     `bson:\"size\" json:\"size\"  `        // e.g. size in bytes\n\tCreatedOn time.Time `bson:\"url\" json:\"url\" yaml:\"URL\"` // e.g. creation of local copy\n}\n```\nItem information to manage file expiration on cache servers\n\n","path":"github.com/MG-RAST/Shock/shock-server/cache","name":"cache","synopsis":"","isRedistributable":true}
