public Post AddPost(Post post) { User user = redis.Get <User>("user:"******"followers:" + post.UserID, 0, -1); allFolowers.Add(post.UserID); redis.LPush("timeline", Encoding.UTF8.GetBytes(postID));//globalna lista postova korisnici mogu da vide objave svih korisnika bez obzila da li ih prate ili ne //meni treba lPush ovo dole je RPush //redis.PushItemToList("timeline", postID); redis.TrimList("timeline", 0, 500); foreach (string followerId in allFolowers) { redis.LPush("posts:" + followerId, Encoding.UTF8.GetBytes(postID)); } return(pm.LoadPost(postID)); }
public List <Post> GetTimeLinePosts(int start, int stop)//vraca praznu listu ako nema nijednog posta (lako moze da se ubaci stranicenje) { List <Post> timeLinePosts = new List <Post>(); PostManipulate pm = new PostManipulate(); byte[][] timeline = redis.LRange("timeline", start, stop);//za sad vracam sve postove foreach (byte[] post in timeline) { string postId = Encoding.UTF8.GetString(post); timeLinePosts.Add(pm.LoadPost(postId)); } return(timeLinePosts); }
public List <Post> GetAllUserPosts(string userId, int start, int stop) { List <Post> userPosts = new List <Post>(); PostManipulate pm = new PostManipulate(); byte[][] timeline = redis.LRange("posts:" + userId, start, stop); foreach (byte[] post in timeline) { string postId = Encoding.UTF8.GetString(post); userPosts.Add(pm.LoadPost(postId)); } return(userPosts); }