Best practice for deferred evaluation/batch processing of snippets
36 lượt xem
Chuyển tới thư đầu tiên chưa đọc
Colin Dellow
chưa đọc,
10:07:25 11 thg 4, 201211/4/12
Trả lời tác giả
Hãy đăng nhập để trả lời tác giả
Chuyển tiếp
Hãy đăng nhập để chuyển tiếp
Xoá
Bạn không có quyền xóa bài viết trong nhóm này
Sao chép đường liên kết
Báo cáo bài viết
Đăng nhập để báo cáo bài viết
Hiển thị bài viết gốc
Địa chỉ email được ẩn danh với nhóm này hoặc bạn cần có quyền xem địa chỉ email của thành viên để có thể xem được bài viết gốc
đến Lift
I need to do an expensive operation (a DB request, a file system
check), potentially N times. I'd like to batch up the requests so I
only pay the network latency cost once. This works if only a single
massive snippet is reponsible for all the requests, but not so well if
multiple snippets contribute to the final document, all of which may
need to do the operation.
Is there a way to defer snippet evaluation until the last minute,
where a method has access to the entire output and can batch things
up?
The approach I'm currently thinking of is to emit something like
<makeLink id="baz"/>, hook into LiftRules.convertResponse and do a
transformation there, which feels a bit dirty.
David Pollak
chưa đọc,
13:36:22 11 thg 4, 201211/4/12
Trả lời tác giả
Hãy đăng nhập để trả lời tác giả
Chuyển tiếp
Hãy đăng nhập để chuyển tiếp
Xoá
Bạn không có quyền xóa bài viết trong nhóm này
Sao chép đường liên kết
Báo cáo bài viết
Đăng nhập để báo cáo bài viết
Hiển thị bài viết gốc
Địa chỉ email được ẩn danh với nhóm này hoặc bạn cần có quyền xem địa chỉ email của thành viên để có thể xem được bài viết gốc
đến lif...@googlegroups.com
You can run multiple snippets in parallel using Parallel Rendering:
If you are looking to do an expensive computation to share across multiple snippets, you can use RequestVars and have the computation be the default value of the RequestVar... that way the result is cached.
Địa chỉ email được ẩn danh với nhóm này hoặc bạn cần có quyền xem địa chỉ email của thành viên để có thể xem được bài viết gốc
đến Lift
> You can run multiple snippets in parallel using Parallel Rendering:http://seventhings.liftweb.net/parallel >
> If you are looking to do an expensive computation to share across multiple
> snippets, you can use RequestVars and have the computation be the default
> value of the RequestVar... that way the result is cached.
Ah, a lightbulb just went off for me. Thank you! Parallel snippets + a
RequestVar to cache previous lookups should get me there.