Skip to content

monchopena/express-wordpressapi-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express.js, Wordrpress API and Cache

This is a sample made with express.js and 2 libraries: node-wpapi and node-cache.

git clone https://github.com/monchopena/express-wordpressapi-cache
cd express-wordpressapi-cache
npm i
npm start

Go to http://localhost:3000/.

Into "lib/wordpress.js" you can put your API url page.

This is the file where we are checking if we can access to cached data "routes/index.js".

var isCached = 'posts';
var cachePosts = cache.get(isCached);

If we can't access to cached data then we get the posts from the API and then create the cache.

Into the file "routes/index":

cache.put('posts', passPosts, 5000); // 5 seconds

In this case we put 5000ms. If time isn't passed in, it is stored forever.

Using cache, displaying the pages will be much more efficient.

The blog entry.

About

This is a sample about how to use cache library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published