api

package
v0.0.0-...-5465ba9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DocLru = NewLru(10 * 1000)

DocLru 默认缓存 10w个文档, 如果文档大小 1kb 则是 100000kb

View Source
var ThemeCache map[string]*entity.Theme
View Source
var UrlCacheObj = NewUrlCache()

Functions

func InitCache

func InitCache()

Types

type APIDoc

type APIDoc struct {
}

func (*APIDoc) Get

func (api *APIDoc) Get(theme string, docId string) (*entity.Doc, error)

func (*APIDoc) GetTerm

func (api *APIDoc) GetTerm(theme string, docId string) ([]string, error)

func (*APIDoc) Set

func (api *APIDoc) Set(theme string, doc *entity.Doc) error

Set 写入文档

func (*APIDoc) SumMD5

func (api *APIDoc) SumMD5(doc *entity.Doc) (string, error)

type APIFenCi

type APIFenCi struct {
}

func (*APIFenCi) TermExtract

func (api *APIFenCi) TermExtract(str string) []*entity.Term

TermExtract 索引词提取

type APISearch

type APISearch struct {
}

func (*APISearch) GetTermData

func (api *APISearch) GetTermData(theme, word, sortType string, pg int) []*entity.PL

func (*APISearch) Search

func (api *APISearch) Search(theme, word, sortType string, pg, count int) ([]*entity.PLTerm, error)

func (*APISearch) SearchFull

func (api *APISearch) SearchFull(theme, word, sortType string, pg, count int) ([]*FullList, error)

func (*APISearch) SearchId

func (api *APISearch) SearchId(theme, word, sortType string, pg, count int) ([]string, error)

func (*APISearch) SearchList

func (api *APISearch) SearchList(theme, word, sortType string, pg, count int) ([]*OutList, error)

type APITheme

type APITheme struct {
}

func (*APITheme) Created

func (api *APITheme) Created(theme *entity.Theme) error

func (*APITheme) Get

func (api *APITheme) Get(name string) (*entity.Theme, error)

func (*APITheme) GetAll

func (api *APITheme) GetAll() []*entity.Theme

func (*APITheme) GetAllName

func (api *APITheme) GetAllName() []string

func (*APITheme) Set2File

func (api *APITheme) Set2File(theme *entity.Theme) error

func (*APITheme) ThemeCacheGet

func (api *APITheme) ThemeCacheGet(theme string) (*entity.Theme, error)

func (*APITheme) ThemeCacheInit

func (api *APITheme) ThemeCacheInit()

ThemeCacheInit ThemeCache 初始化

type FullList

type FullList struct {
	Id          string  `json:"id"`
	Title       string  `json:"title"`
	TimeStamp   int64   `json:"timestamp"`
	Author      string  `json:"author"`
	OrderInt    int64   `json:"order_int"`
	Description string  `json:"description"`
	Content     string  `json:"content"`
	End         int     `json:"end"`
	Start       int     `json:"start"`
	Theme       string  `json:"theme"`
	SortType    string  `json:"sort_type"`
	SortValue   float64 `json:"sort_value"`
	Md5         string  `json:"md5"`
}

type Lru

type Lru interface {
	Get(key string) (value *entity.Doc, ok bool)
	GetKeyFromValue(value *entity.Doc) (key string, ok bool)
	Put(key string, value *entity.Doc)
}

Lru 文档缓存, LRU算法 key theme_docId value doc

func NewLru

func NewLru(cap int) Lru

NewLru initializes a lru cache

type OutList

type OutList struct {
	Id        string `json:"id"`
	Title     string `json:"title"`
	TimeStamp int64  `json:"timestamp"`
	Author    string `json:"author"`
}

type UrlBody

type UrlBody struct {
	Body       interface{}
	Count      int
	Url        string
	Expiration int64 // 过期时间
}

func (*UrlBody) Expired

func (udp *UrlBody) Expired() bool

Expired 判断数据项是否已经过期

type UrlCache

type UrlCache struct {
	// contains filtered or unexported fields
}

func NewUrlCache

func NewUrlCache() *UrlCache

func (*UrlCache) DeleteExpired

func (c *UrlCache) DeleteExpired()

DeleteExpired 删除过期数据项

func (*UrlCache) Get

func (c *UrlCache) Get(k string) (*UrlBody, bool)

Get 获取数据项

func (*UrlCache) Set

func (c *UrlCache) Set(urlStr string, body *UrlBody)

Set 设置缓存数据项,如果数据项存在则覆盖

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL