-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern caching #32
Comments
There is actually a cache built-in. But it only holds weak references, to not cause a memory leak. 2.1.2 :001 > x = Mustermann.new "/foo"
=> #<Mustermann::Sinatra:"/foo">
2.1.2 :002 > y = Mustermann.new "/foo"
=> #<Mustermann::Sinatra:"/foo">
2.1.2 :003 > x.object_id
=> 70336235790360
2.1.2 :004 > y.object_id
=> 70336235790360
2.1.2 :005 > x = y = nil
=> nil
2.1.2 :006 > GC.start
=> nil
2.1.2 :007 > x = Mustermann.new "/foo"
=> #<Mustermann::Sinatra:"/foo">
2.1.2 :008 > x.object_id
=> 70336230084880 |
GREAT! Please update the documentation. I think this can be closed then... |
Hmm, doesn't work for me (My thing runs only half as fast). Either it is not working or the gc kicks in all the time :( |
Yeah, that might be. Which is why I'd rather not recommend relying on it. What Ruby version are you on? On Thu, Aug 14, 2014 at 5:01 PM, Daniel Mendler notifications@github.com
|
I am not perfectly sure if it makes sense in this library, but you could maybe provide a constructor which returns cached Mustermänner. But maybe you rather want to rely on Sinatra or the user?
Currently the docs say:
The text was updated successfully, but these errors were encountered: