示例#1
0
文件: blog.go 项目: HYQMartin/star
func NIdByIdent(ident string) int64 {
	if ident == "" {
		return 0
	}

	val := g.NBlogCacheGet(ident)
	if val == nil {
		if p := NOneByIdentInDB(ident); p != nil {
			g.NBlogCachePut(ident, p.Id)
			return p.Id
		} else {
			return 0
		}
	}

	return val.(int64)
}
示例#2
0
文件: blog.go 项目: HYQMartin/star
func NReadBlogContent(b *NewemployeeBlog) *NewemployeeBlogContent {
	if b.Id <= 0 || b.BlogContentId <= 0 {
		return nil
	}

	key := fmt.Sprintf("content_of_%d_%d", b.Id, b.BlogContentLastUpdate)
	val := g.NBlogCacheGet(key)
	if val == nil {
		if p := NreadBlogContentInDB(b); p != nil {
			g.NBlogCachePut(key, *p)
			return p
		}
		return nil
	}
	ret := val.(NewemployeeBlogContent)
	return &ret
}
示例#3
0
文件: blog.go 项目: HYQMartin/star
func NOneById(id int64) *NewemployeeBlog {
	if id <= 0 {
		return nil
	}

	key := fmt.Sprintf("%d", id)
	val := g.NBlogCacheGet(key)
	if val == nil {
		if p := NOneByIdInDB(id); p != nil {
			g.NBlogCachePut(key, *p)
			return p
		}
		return nil
	}
	ret := val.(NewemployeeBlog)
	return &ret
}
示例#4
0
文件: blog.go 项目: HYQMartin/star
func NIds(catalog_id int64) []int64 {
	if catalog_id <= 0 {
		return []int64{}
	}

	key := fmt.Sprintf("article_ids_of_%d", catalog_id)
	val := g.NBlogCacheGet(key)
	if val == nil {
		if ids := NIdsInDB(catalog_id); len(ids) != 0 {
			g.NBlogCachePut(key, ids)
			return ids
		} else {
			return []int64{}
		}
	}

	return val.([]int64)
}