Implementing Follow,tag,feed System with node plus Redis

Source: Internet
Author: User

https://cnodejs.org/topic/53ad78f2c3ee0b5820f74298

Follow,tag, and feed system are very suitable for using Redis to implement, take the tag system as an example: User Ltebean to add a label to Nodejs amazing is:

sadd user:ltebean:tag:amazing nodejssadd user:ltebean:item:nodejs amazing

A reverse relationship is saved in order to be able to check according to tag, and the following is the command of Redis:

Get all the Nodejs tags:

smembers user:ltebean:item:nodejs

Get all the item under tag amazing:

smembers user:ltebean:tag:amazing

Get the item with both a amazing tag and a Web label hit

sunion user:ltebean:tag:amazing user:ltebean:tag:web

Here is the API implemented by Nodejs:

Taggie.User(' Ltebean ').Item(' Bootstrap ').Addtag(' CSS ', function(Err,Res) {});Taggie.User(' Ltebean ').Item(' Bootstrap ').Addtag(' Web ', function(Err,Res) {});Taggie.User(' Ltebean ').Item(' jquery ').Addtag(' Web ', function(Err,Res) {});Taggie.User(' Ltebean ').Item(' jquery ').Addtag(' JS ', function(Err,Res) {});Taggie.User(' Ltebean ').Item(' Nodjs ').Addtag(' JS ', function(Err,Res) {});Taggie.User(' Ltebean ').Item(' jquery ').AllTags(function(Err,Res) {Console.Log("jquery s Tag:%s",Res); jquery ' s Tag:js,web});Taggie.User(' Ltebean ').Item().AllItems(function(Err,Res) {Console.Log("All Items:%s",Res); All Items:jquery,nodjs,bootstrap});Taggie.User(' Ltebean ').Tag(' Web ').AllItems(function(Err,Res){Console.Log(' Tagged with Web:%s ',Res); Tagged with web:jquery,bootstrap});Taggie.User(' Ltebean ').Tag().AllTags(function(Err,Res){Console.Log(' All Tags:%s ',Res); All Tags:js,web,css});Taggie.User(' Ltebean ').Tag([' Web ',' JS ']).Itemsbyinter(function(Err,Res){Console.Log(' Tagged with Web and js:%s ',Res); Tagged with web and js:jquerytaggie. "Ltebean"  ([ ' web ' itemsbyunion (function ( Err,res) { Console.< Span class= "PLN" >log (res);  //tagged with Web or js:jquery,nodjs,bootstrap                

User follow and feed system implementation is similar, finally attached three items address: Taggie:https://github.com/ltebean/taggie user-graph:https://github.com/ Ltebean/user-graph Feedie:https://github.com/ltebean/feedie

Implementing Follow,tag,feed System with node plus Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.