开发者

Flush DataMapper's identity map in Rails 3

I'm doing some performance testing and DataMap开发者_开发问答per's identity map is getting in my way. How do I flush it?


In DataMapper the Identity Map is only in effect within the scope of a repository block. Inside the scope of that block you can do:

model.repository.identity_map(model).clear

The IM is keyed by the model, so there's no way to find all the IM's for all the models in one call; you essentially would have to iterate through each model's IM and clear them one at a time.

Keep in mind this isn't part of the documented API, so may be subject to change in future versions of DM. However (speaking as the DataMapper maintainer) it's unlikely to change in the 1.x series, but most likely will change for 2.x

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜