Ejemplo n.º 1
0
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)
}
Ejemplo n.º 2
0
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
}
Ejemplo n.º 3
0
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
}
Ejemplo n.º 4
0
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)
}