public void AddUserInformation(User user) { string serializedUser = ObjectSerializer.SerializeUser(user); string listId = KeysDictionary.UserInformation(user.Username); redis.Add(listId, serializedUser); }
public void AddCommentOnPost(CommentOnPost c) { string postKey = KeysDictionary.PostKey(c.Post.Id); string serializedComment = ObjectSerializer.SerializeComment(c); redis.PushItemToList(postKey, serializedComment); }
public void AddVisitedPlace(string username, Place place) { string serializedPlace = ObjectSerializer.SerializePlace(place); string listId = KeysDictionary.PlacesVisitedKey(username); redis.PushItemToList(listId, serializedPlace); }
public string CreatePlaceId() { string placeIdKey = KeysDictionary.PlaceIdKey(); long id = redis.Incr(placeIdKey); return(id.ToString()); }
public string GetNextCommentId() { string commentId = KeysDictionary.CommentIdKey(); long id = redis.Incr(commentId); return(id.ToString()); }
public void EditUserInformation(User user) { string serializedUser = ObjectSerializer.SerializeUser(user); string userKey = KeysDictionary.UserInformation(user.Username); redis.Remove(userKey); redis.Add(userKey, serializedUser); }
public void AddUserPost(Post post) { string serializedPost = ObjectSerializer.SerializeRating(post); string username = post.User.Username; string listId = KeysDictionary.UserPosts(username); redis.PushItemToList(listId, serializedPost); }
public void AddPlacePost(Post post) { string serializedPost = ObjectSerializer.SerializeRating(post); string placeId = post.Place.Id; string listId = KeysDictionary.PlacePosts(placeId); redis.PushItemToList(listId, serializedPost); }
public User GetUser(string username) { string listId = KeysDictionary.UserInformation(username); string serializedUser = redis.Get <string>(listId); User user = ObjectDeserializer.DeserializeUser(serializedUser); return(user); }
public void StoreUserInformation(List <User> users) { foreach (var user in users) { string listId = KeysDictionary.UserInformation(user.Username); string serializedUser = ObjectSerializer.SerializeUser(user); redis.PushItemToList(listId, serializedUser); } }
public void AddVisitor(Post post) { string placeId = post.Place.Id; User user = post.User; string serializedUser = ObjectSerializer.SerializeUser(user); string listId = KeysDictionary.PlaceRecentVisitors(placeId); redis.PushItemToList(listId, serializedUser); }
public void StorePlacesVisited(string username, List <Place> places) { string listId = KeysDictionary.PlacesVisitedKey(username); foreach (var place in places) { string serializedPlace = ObjectSerializer.SerializePlace(place); redis.PushItemToList(listId, serializedPlace); } }
public void StoreUserPosts(string username, List <Post> posts) { string listId = KeysDictionary.UserPosts(username); foreach (var post in posts) { string serializedPost = ObjectSerializer.SerializeRating(post); redis.PushItemToList(listId, serializedPost); } }
public void AddPostPicturesToGallery(Post post) { string placeId = post.Place.Id; string listId = KeysDictionary.PlaceGallery(placeId); foreach (var picture in post.Pictures) { string serializedPicture = ObjectSerializer.SerializePicture(picture); redis.PushItemToList(listId, serializedPicture); } }
public List <Post> GetNewsFeed(string username) { List <Post> posts = new List <Post>(); string listId = KeysDictionary.UserNewsFeed(username); foreach (string postString in redis.GetRangeFromList(listId, 0, NewsFeedLength - 1)) { Post post = ObjectDeserializer.DeserializeRating(postString); posts.Add(post); } return(posts); }
public string GetOldestPostId(string username) { string listId = KeysDictionary.UserNewsFeed(username); string obj = redis.GetItemFromList(listId, 0); Post p = ObjectDeserializer.DeserializeRating(obj); if (p != null) { return(p.Id); } else { return(Int32.MaxValue.ToString()); } }
public List <Picture> GetPlaceGallery(string placeId) { string listId = KeysDictionary.PlaceGallery(placeId); int listCount = (int)redis.GetListCount(listId); List <Picture> pictures = new List <Picture>(); foreach (string placeString in redis.GetRangeFromList(listId, 0, listCount - 1)) { Picture picture = ObjectDeserializer.DeserializePicture(placeString); pictures.Add(picture); } return(pictures); }
public List <Place> GetRecentVisitedPlaces(string username, int numberOfPlaces) { List <Place> places = new List <Place>(); string listId = KeysDictionary.PlacesVisitedKey(username); int listCount = (int)redis.GetListCount(listId); int startIndex = listCount - numberOfPlaces; foreach (string placeString in redis.GetRangeFromList(listId, startIndex, listCount - 1)) { Place place = ObjectDeserializer.DeserializePlace(placeString); places.Add(place); } return(places); }
public List <Post> GetRecentPlacePosts(string placeId, int numberOfPosts) { List <Post> posts = new List <Post>(); string listId = KeysDictionary.PlacePosts(placeId); int listCount = (int)redis.GetListCount(listId); int startIndex = listCount - numberOfPosts; foreach (string postString in redis.GetRangeFromList(listId, startIndex, listCount - 1)) { Post post = ObjectDeserializer.DeserializeRating(postString); posts.Add(post); } return(posts); }
//deprecated public List <User> GetRecentVisitors(string placeId, int numberOfVisitors) { List <User> users = new List <User>(); string listId = KeysDictionary.PlaceRecentVisitors(placeId); int listCount = (int)redis.GetListCount(listId); int startIndex = listCount - numberOfVisitors; foreach (string userString in redis.GetRangeFromList(listId, startIndex, listCount - 1)) { User user = ObjectDeserializer.DeserializeUser(userString); users.Add(user); } return(users); }
public List <CommentOnPost> GetCommentsLastN(string postId, int n) { string postKey = KeysDictionary.PostKey(postId); int listCount = (int)redis.GetListCount(postId); int startIndex = listCount - n; List <CommentOnPost> result = new List <CommentOnPost>(); List <string> list = redis.GetRangeFromList(postKey, startIndex, n); foreach (string s in list) { result.Add(ObjectDeserializer.DeserializeComment(s)); } return(result); }
public void AddPostToNewsFeed(string friendUsername, Post post) { string serializedPost = ObjectSerializer.SerializeRating(post); string username = post.User.Username; string listId = KeysDictionary.UserNewsFeed(friendUsername); redis.PushItemToList(listId, serializedPost); int listCount = (int)redis.GetListCount(listId); int startIndex = listCount - NewsFeedLength; if (startIndex < 0) { startIndex = 0; } redis.TrimList(listId, startIndex, listCount); }
public void StoreToUserNewsFeed(string username, List <Post> posts) { string listId = KeysDictionary.UserNewsFeed(username); foreach (var post in posts) { string serializedPost = ObjectSerializer.SerializeRating(post); redis.PushItemToList(listId, serializedPost); } int listCount = (int)redis.GetListCount(listId); int startIndex = listCount - NewsFeedLength; if (startIndex < 0) { startIndex = 0; } redis.TrimList(listId, startIndex, listCount); }