Documentation
¶
Overview ¶
Package fcache provides named cache for functions results
supported functions are:
- Output for OutPutters: Output() ([]byte, error)
cache backend is filesystem directory, and functions are protected by a Lock/Unlock lock := func(name string) Locker
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Output ¶
func Output(o Outputter, sig string, dir string, lockDuration time.Duration, lockP func(name string) Locker) (out []byte, err error)
Output function returns previous o.Output() results named 'sig' from 'cacheDir', if not found in cache a new value is computed, and cache is updated.
A lock object associated with 'sig' (created by function 'lockP') is used,
When lock error:
Returns o.Output() (no update cache).
When locked:
returns found cache entry associated with 'sig' from 'cacheDir'. If entry is not present, it runs 'o.Output()'. In case of error during o.Output(), the error is returned and cache is not updated, else cache associated with 'sig' is updated and new cached value is returned.
dir is created if absent, lockDuration is the maximum duration to wait for lock step.
Types ¶
Click to show internal directories.
Click to hide internal directories.