Created
June 4, 2010 17:02
-
-
Save stve/425666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| plugin MongoMapper::Plugins::IdentityMap | |
| end | |
| Or you can add to all documents like this: | |
| module IdentityMapAddition | |
| def self.included(model) | |
| model.plugin MongoMapper::Plugins::IdentityMap | |
| end | |
| end | |
| MongoMapper::Document.append_inclusions(IdentityMapAddition) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PerRequestCache | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| MongoMapper::Plugins::IdentityMap.clear | |
| @app.call(env) | |
| ensure | |
| MongoMapper::Plugins::IdentityMap.clear | |
| end | |
| end | |
| config.middleware.use 'PerRequestCache' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment