开发者

Flush DataMapper's identity map in Rails 3

开发者 https://www.devze.com 2023-02-24 22:10 出处:网络
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 reposit

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

精彩评论

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