Since this is my first time writing Raven Database code, i wanted to make sure that my model isn't messing things up and my queries are possible and Valid.Here's my model ( It's a CMS project designed for weird-customer needs -_- )
class DenormalizedUserInfo
{
public string EmailAddress {get;set;}
public string FirstName {get;set;}
public string LastName {get;set;}
}
class Comment
{
public string Id {get;set;}
public string Url {get;set;}
public string Content {get;set;}
public DateTime CreationTime {get;set;}
public DenormalizedUserInfo UserInfo{get;set;}
public int LikesCount {get;set;}
public int DisLikesCount {get;set;}
}
class CommentCollection
{
public string Url {get;set;}
public SortedSet<Comment> Comments {get;set;}
}
class Post
{
public string Id {get;set;}
public string Url {get;set;}
public string Content {get;set;}
public DateTime CreationTime {get;set;}
public DenormalizedUserInfo UserInfo {get;set;}
public int LikesCount {get;set;}
public int DisLikeCount {get;set;}
public SortedSet<Comments> RelatedComments {get;set;}
}
The user usecases are: 1- add/remove/modify posts (according to ID). 2- Add/remove/like/dislike comment on a Post (according to [PostID,CommentID] pair).
3-Add/remove/like/dislike comment on a CommentCollection (according to (Url,CommentID) pairs).
I was able to create Indexing classes for: getting a post by Id, post by URL, post by user, commentcollection by Url.
Hah ... that was alot of talk (sorry for talking so long) .. anyway .. my concerns are :
1- In usecases (2) i have to have two pieces of information (namely, postId and CommentId) inorder to get the right object. is there a way to get it using only CommentId by indexing and querying on commentId somehow ? This also applies to usecase (3).
2- Access to my data objects is multi-threaded. Do i need some locking mechanism for my fields when they're modified by multiple threads at the same time (say, two users wanted to add a comment to a post at the same time), or does raven handle this by itself? if so, then how !?
3- I'm using Raven Server over Http (because you recommended this for production). I've read that it provides caching of objects in memory. How does raven alter this cache when i modify a document that is currently in cache ?
Thanx ..