开发者

Frameworks using Redis

I would like to know if 开发者_StackOverflow中文版there are any MVC framework compatible with Redis as a database. (Not just as a caching datastore).

Thanks


I would not expect any MVC framework to be tied to a database. Your implementation of the Model would provide access to whatever backing store (either directly or via one or more layers) was appropriate. You should be looking at the clients that Redis supports, with those you should be able to utilise MVC frameworks on any of the support client platforms.


+1 for Padrino.

Another great option is Monk. It includes Ohm(its actually written by some of the same guys) and is based on Sinatra. Its really easy to get started with and very flexible.


In Ruby you can use Ohm as ORM. If you want an MVC framework, it can be plugged to Padrino.


try to investigate cqrs architecture with event sourcing. And you can download example of this from github.it is Ruby on Rails application with Redis DB


You should definitely check out my C# ServiceStack.Redis Client. The client provides a typed API that can store any type and other high-level functionality, i.e. Strong-typed messaging API, Transactional Support, Pipelining, etc.

Here's is an mini clone of Stack Overflow built with it, using only one page of C#:

Sample Code from Redis StackOverflow:

public User GetOrCreateUser(User user)
{
    if (user.DisplayName.IsNullOrEmpty())
        throw new ArgumentNullException("DisplayName");

    var userIdAliasKey = "id:User:DisplayName:" + user.DisplayName.ToLower();

    using (var redis = RedisManager.GetClient())
    {
        //Get a typed version of redis client that works with <User>
        var redisUsers = redis.As<User>();

        //Find user by DisplayName if exists
        var userKey = redis.GetValue(userIdAliasKey);
        if (userKey != null)
            return redisUsers.GetValue(userKey);

        //Generate Id for New User
        if (user.Id == default(long))
            user.Id = redisUsers.GetNextSequence();

        redisUsers.Store(user);

        //Save reference to User key using the DisplayName alias
        redis.SetEntry(userIdAliasKey, user.CreateUrn());

        return redisUsers.GetById(user.Id);
    }
}


grails has redis support in GORM through the redis plugin. Any domain class can be stored in redis (or any one of the other supported nosql stores) instead of a relational database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜