花瓣网的Node.Js ORM框架:Toshihiko

分享到:

目前花瓣网和大搜车都有项目在用该 ORM。

使用很简单,且在上层没做类似于group by,join等降低效率的 API 支持,因为mysql本身效率就不是特别高。

支持三方缓存——比如 memcached,也可以自己实现一个toshihiko-xxx作为自己的缓存层。

You should create aToshihikoobject to connect to MySQL:

var T = require("toshihiko"); 
var toshihiko = new T.Toshihiko(database, username, password, options);

Options can include these things:

  • host: hostname or IP of MySQL. Defaults tolocalhost.
  • port: port of MySQL. Defaults to3306.
  • cache: if you want to cache support, let it be an cache layer object or cache layer configuration which will be mentioned below. Defaults to undefined.
  • etc... (All options in module mysql will be OK)

Cache

Toshihiko now is using new cache layer! You can choose your cache layer by your self!

Pass an object tocacheof options like:

var toshihiko = new T.Toshihiko(database, username, password, {
cache: YOUR_CACHE_LAYER
});

TheYOUR_CACHE_LAYERmay be an instance of Toshihiko cache layer object like toshihiko-memcacehd (you can implement a cache layer by yourself).

What's more,YOUR_CACHE_LAYERmay be a configuration object which should includenameorpath.

For an example,

var toshihiko = new T.Toshihiko(database, username, password, {
cache: {
name: "memcached",
servers: "...",
options: {}
}
});

项目主页:http://www.open-open.com/lib/view/home/1426487330382


昵    称:
验证码:

相关文档: