世界属于将思考付诸实践的人

把ActiveRecord ORM应用到C++中

类归于: 程序开发 — colin @ 6:32 下午 2007年01月06日

ruby on rails采用ActiveRecord方式实现ORM,巧妙的利用动态语言的特性,通过数据存储结构和数据类的各种约定来实现运行时的O-R映射。不同于其它ORM依赖一大堆繁琐配置,Rails中的ORM机制将映射做到最佳自动化,依赖动态语言的反射特性和动态绑定,python\php\c#\java等应该都可以采用这种方式。

其实本没有必要在C++中实现ActiveRecord,将原本编译期绑定的方法花费很大的曲折实现运行期绑定,势必带来性能上较大的下降,何况C++本身不支持反射,虽然可以通过hash等数据结构实现类似的目的,但是代价也很大。所以这一切都注定了C++的ActiveRecord不可能像ruby on rails中表现得那么优美。尽管如此,作为一次试验,我还是会计划去实现它。

计划特性:

  • 为每个数据表模型自动提供基本的CRUD方法
  • 在模型中引入触发事件和过滤器
  • 提供自定义Sql高级find方法
  • 数据访问层独立,目前只支持mysql
  • 提供对外键字段的多表引用
  • 友好的方法
  • 几乎无须任何配置文件

Share/Save/Bookmark

Django’s cache framework

类归于: Open Source, 程序开发 — colin @ 5:31 下午 2007年01月05日

Django Download

http://www.djangoproject.com/download/

Django Cache Framework

http://www.djangoproject.com/documentation/cache/

  • Memcached
  • Database caching
  • Filesystem caching
  • Local-memory caching
  • Simple caching (for development)
  • Dummy caching (for development)
  • Share/Save/Bookmark

    2006·视觉回顾

    类归于: 摄影&游记, 杂谈&日志 — colin @ 9:13 下午 2007年01月03日

    终于到了元旦三天假期,有充足的时间让我拿出2006年的一些照片来,细细的回顾,一直没有贴出来的照片选一些show给朋友们,希望大家在新的一年继续支持Guoxin.Org,保持联系!

    年初的时候,评优秀团队上杂志,几个愤青在一起拍了点合影。

    20071415227158.jpg

    左: roland 中: edward 右: me

    20071415227196.jpg

    7月份部门旅游,去了离深圳不远的一个地方(名字现在都不记得了),爬山、漂流、雪花温泉等。

    200713193938897.jpg

    200713193948107.jpg

    20071415227472.jpg

    深圳万象城——我在深圳最喜欢的一个地方

    20071415227321.jpg

    20071415227563.jpg

    20071415227721.jpg

    200713194016732.jpg

    国庆一周在北京度过,看着王府井的梨园,深感南北文化的差异

    20071415227767.jpg

    20071415227876.jpg

    11月11日,Tencent Birthday。公司在深圳大学组织了一次大型活动,各部门设计自己的收费服务,大家礼尚往来,最后所有收益捐给贫困灾区。

    200713194147456.jpg

    200713194157731.jpg

    20071415227208.jpg

    左:ade(TE) 中:tony(CTO) 右:me

    Share/Save/Bookmark

    元旦爬南山

    类归于: 摄影&游记 — colin @ 6:00 下午 2007年01月01日

    来深圳这么久了,一直没有爬过南山。

    2007年的第一天,一定要爬一次南山,登高望远,新年新气象。

    中午我们从蛇口登山口出发,边聊天边前进,走了不到一会便有点气喘吁吁,看来还是缺乏锻炼了。山路很好走,几乎全部是修好的台阶,但是比较陡。

    很快,我们就到了山顶,不到一个小时的功夫。

    拍下这张照片,前方就是香港岛,还有一条跨海大桥——西部通道,连接深圳蛇口到香港新界,开通后去香港就很容易了,不需要去罗湖坐火车,从我住的地方去新界坐车可能就半个小时的功夫。

    20071317631329.jpg

    下山后,大家来了一顿火锅,一箱啤酒,元旦快乐!

    Share/Save/Bookmark

    MySQL Cluster

    类归于: Web开发, 程序开发 — colin @ 5:26 下午 2006年12月31日

    Mysql5.0引入的服务器集群

    MySQL Cluster is a technology that enables clustering of in-memory databases in a shared-nothing system. The shared-nothing architecture allows the system to work with very inexpensive hardware, and without any specific requirements on hardware or software. It also does not have any single point of failure because each component has its own memory and disk.

    MySQL Cluster integrates the standard MySQL server with an in-memory clustered storage engine called NDB. In our documentation, the term NDB refers to the part of the setup that is specific to the storage engine, whereas “MySQL Cluster” refers to the combination of MySQL and the NDB storage engine.

    A MySQL Cluster consists of a set of computers, each running a one or more processes which may include a MySQL server, a data node, a management server, and (possibly) a specialized data access programs. The relationship of these components in a cluster is shown here:

    2007170426821.png

    All these programs work together to form a MySQL Cluster. When data is stored in the NDB Cluster storage engine, the tables are stored in the data nodes. Such tables are directly accessible from all other MySQL servers in the cluster. Thus, in a payroll application storing data in a cluster, if one application updates the salary of an employee, all other MySQL servers that query this data can see this change immediately.

    The data stored in the data nodes for MySQL Cluster can be mirrored; the cluster can handle failures of individual data nodes with no other impact than that a small number of transactions are aborted due to losing the transaction state. Because transactional applications are expected to handle transaction failure, this should not be a source of problems.

    Share/Save/Bookmark