国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

mongodb - express做的文章管理網(wǎng)站,文章分類(lèi)查詢(xún)問(wèn)題,如何實(shí)現(xiàn)只查詢(xún)一次數(shù)據(jù)庫(kù)?
淡淡煙草味
淡淡煙草味 2017-04-26 09:01:39
0
6
834

express寫(xiě)的文章管理系統(tǒng),每個(gè)頁(yè)面的菜單導(dǎo)航欄都是一樣的,但是每個(gè)頁(yè)面都從數(shù)據(jù)庫(kù)去查詢(xún)了一次所有的菜單。

怎么使整個(gè)網(wǎng)站只從數(shù)據(jù)庫(kù)查詢(xún)一次菜單,然后把數(shù)據(jù)給每個(gè)頁(yè)面使用呢?

數(shù)據(jù)庫(kù)用的 MongoDB

工具用的 mongoose

淡淡煙草味
淡淡煙草味

reply all(6)
巴扎黑

I don’t knownode, is it possible to load the menu data when it is started and put the menu data into global variables?

迷茫

Personally, I think you can do a layer of caching.

劉奇

Split the page and introduce additional ejs subpages.

Ty80

https://github.com/hubwiz/example-node

大家講道理

You can save it in cache

洪濤

Cache, is it useful for redis?
Or you bind it to app.locals, check it, if there is a menu, just get it directly, if not, go to the database to query and bind it.
In this way, you can get it directly every time. Of course, if you update, the menu should also be updated on app.locals.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template