Documentation ¶
Index ¶
- Constants
- func CleanRecords()
- func CreateAllCachedirs()
- func Len() int
- func RemoveRemoved()
- type Cache
- func (c *Cache) CheckData(res string, stamp int64, id string, begin, end int64) error
- func (c *Cache) Exists() bool
- func (c *Cache) GetContents() []string
- func (c *Cache) Gettitle() string
- func (c *Cache) HasRecord() bool
- func (c *Cache) Len() int
- func (c *Cache) LoadRecords(kind int) record.Map
- func (c *Cache) RecentStamp() int64
- func (c *Cache) Remove()
- func (c *Cache) Size() int64
- func (c *Cache) Stamp() int64
- func (c *Cache) Subscribe()
- func (c *Cache) Velocity() int
- type Caches
- type SortByStamp
- type SortByVelocity
Constants ¶
const ( //Alive counts records that are not removed. Alive = 1 //Removed counts records that are removed. Removed = 2 //All counts all records All = 3 )
Variables ¶
This section is empty.
Functions ¶
func CleanRecords ¶ added in v0.1.0
func CleanRecords()
CleanRecords remove old or duplicates records for each Caches.
func CreateAllCachedirs ¶ added in v0.1.0
func CreateAllCachedirs()
CreateAllCachedirs creates all dirs in recentlist to be retrived when called recentlist.getall. (heavymoon)
func RemoveRemoved ¶ added in v0.1.0
func RemoveRemoved()
RemoveRemoved removes files in removed dir if old.
Types ¶
type Cache ¶
type Cache struct {
Datfile string
}
Cache represents cache of one file.
func NewCache ¶
NewCache read tag files to set and returns cache obj. it uses sync.pool to ensure that only one cache obj exists for one datfile. and garbage collected when not used.
func (*Cache) CheckData ¶ added in v0.1.0
CheckData makes a record from res and checks its records meets condisions of args. adds the rec to cache if meets conditions. if spam or big data, remove the rec from disk. returns count of added records to the cache and spam/getting error.
func (*Cache) GetContents ¶
GetContents returns recstrs of cache. len(recstrs) is <=2.
func (*Cache) HasRecord ¶
HasRecord return true if cache has more than one records or removed records.
func (*Cache) LoadRecords ¶
LoadRecords loads and returns record maps from the disk..
func (*Cache) RecentStamp ¶
RecentStamp returns time of getting by /recent.
type Caches ¶
type Caches []*Cache
Caches is a slice of *cache
func MakeRecentCachelist ¶ added in v0.1.0
func MakeRecentCachelist() Caches
MakeRecentCachelist returns sorted cachelist copied from Recentlist. which doens't contain duplicate Caches.
type SortByStamp ¶
type SortByStamp struct { Caches // contains filtered or unexported fields }
SortByStamp is for sorting by stamp.
func NewSortByStamp ¶
func NewSortByStamp(cs Caches, recentStamp bool) *SortByStamp
NewSortByStamp makes stamps for caches and returns SortByStamp obj.
func (*SortByStamp) Less ¶
func (c *SortByStamp) Less(i, j int) bool
Less returns true if cache[i].stamp < cache[j].stamp.
type SortByVelocity ¶
type SortByVelocity struct { Caches // contains filtered or unexported fields }
SortByVelocity is for sorting by velocity.
func NewSortByVelocity ¶
func NewSortByVelocity(cs Caches) *SortByVelocity
NewSortByVelocity makes velocity for caches and returns SortByVelocity obj.
func (*SortByVelocity) Less ¶
func (c *SortByVelocity) Less(i, j int) bool
Less returns true if cache[i].velocity < cache[j].velocity. if velocity[i]==velocity[j], returns true if cache[i].size< cache[j].size.
func (*SortByVelocity) Swap ¶
func (c *SortByVelocity) Swap(i, j int)
Swap swaps order of cache slice.