[Lift] Re: Potential LiftRules dispatch issue.
On this note, I wrote an image cache for use in conjunction with MappedBinary - if anyone is interested I'm happy to post the code. It uses EHCache and first checks the cache for the right image, and grabs it if it's there, otherwise it does the database read. If your needing to store images in the database, using an object cache can vastly cut the amount of DB access and reduce server load Cheers Tim On Jan 28, 12:00 am, Alli wrote: > Thanks, will definitely order a PDF or your book when it's out. > > Cheers, > Alli > > On Jan 27, 11:56 pm, David Pollak > wrote: > > > On Tue, Jan 27, 2009 at 3:53 PM, Alli wrote: > > > > Is it possible to make the extension a wild card somehow, e.g. > > > if i want jpg,png,gif,bmp ? > > > LiftRules.dispatch.append { > > case r @ Req("picture" :: fileName :: Nil, extension, GetRequest) if > > List("jpg", "png", "gif").contains(extension) => () => > > ... > > > } > > > Note that this is not a speed-optimal solution (you'd pre-populate set with > > the valid extensions). But it demonstrates using extractors and guards... > > the stuff I'm writing about this very day in *Beginning Scala*. > > > Thanks, > > David > > > > On Jan 27, 11:50 pm, Alli wrote: > > > > Thanks chaps, can't believe i didn't spot it :). > > > > > Cheers, > > > > Alfred > > > > > On Jan 27, 11:48 pm, Tim Perrett wrote: > > > > > > Change the req to this: > > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > > That should then work for you > > > > > > Cheers, Tim > > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > > LiftRules.dispatch.append { > > > > > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () > > > > > > => > > > > > > ... > > > > > > > } > > > -- > > Lift, the simply functional web frameworkhttp://liftweb.net > > Beginning > > Scalahttp://www.amazon.com/Beginning-Scala-David-Pollak/dp/1430219890/ref=... > > Follow me:http://twitter.com/dpp > > Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
Hi, I'd be interested to have a look at the code :) I was about to do the same. I'd planned to use a simple cache (by uuid) in a concurrent, weak map but EHCache might be the better solution, I guess. Thanks a lot, Joachim > On this note, I wrote an image cache for use in conjunction with > MappedBinary - if anyone is interested I'm happy to post the code. It > uses EHCache and first checks the cache for the right image, and grabs > it if it's there, otherwise it does the database read. If your needing > to store images in the database, using an object cache can vastly cut > the amount of DB access and reduce server load > > Cheers > > Tim > > On Jan 28, 12:00 am, Alli wrote: > > Thanks, will definitely order a PDF or your book when it's out. > > > > Cheers, > > Alli > > > > On Jan 27, 11:56 pm, David Pollak > > > > wrote: > > > On Tue, Jan 27, 2009 at 3:53 PM, Alli wrote: > > > > Is it possible to make the extension a wild card somehow, e.g. > > > > if i want jpg,png,gif,bmp ? > > > > > > LiftRules.dispatch.append { > > > case r @ Req("picture" :: fileName :: Nil, extension, GetRequest) if > > > List("jpg", "png", "gif").contains(extension) => () => > > > ... > > > > > > } > > > > > > Note that this is not a speed-optimal solution (you'd pre-populate set > > > with the valid extensions). But it demonstrates using extractors and > > > guards... the stuff I'm writing about this very day in *Beginning > > > Scala*. > > > > > > Thanks, > > > David > > > > > > > On Jan 27, 11:50 pm, Alli wrote: > > > > > Thanks chaps, can't believe i didn't spot it :). > > > > > > > > > > Cheers, > > > > > Alfred > > > > > > > > > > On Jan 27, 11:48 pm, Tim Perrett wrote: > > > > > > Change the req to this: > > > > > > > > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > > > > > > > > That should then work for you > > > > > > > > > > > > Cheers, Tim > > > > > > > > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > > LiftRules.dispatch.append { > > > > > > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => > > > > > > > () => ... > > > > > > > > > > > > > > } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
IMHO, a third party cache is a huge waste. Lift has net.liftweb.util.LRU for this purpose. On Wed, Jan 28, 2009 at 11:33 AM, Joachim A. wrote: > > Hi, > I'd be interested to have a look at the code :) > I was about to do the same. I'd planned to use a simple cache (by uuid) in > a > concurrent, weak map but EHCache might be the better solution, I guess. > > Thanks a lot, > Joachim > > > On this note, I wrote an image cache for use in conjunction with > > MappedBinary - if anyone is interested I'm happy to post the code. It > > uses EHCache and first checks the cache for the right image, and grabs > > it if it's there, otherwise it does the database read. If your needing > > to store images in the database, using an object cache can vastly cut > > the amount of DB access and reduce server load > > > > Cheers > > > > Tim > > > > On Jan 28, 12:00 am, Alli wrote: > > > Thanks, will definitely order a PDF or your book when it's out. > > > > > > Cheers, > > > Alli > > > > > > On Jan 27, 11:56 pm, David Pollak > > > > > > wrote: > > > > On Tue, Jan 27, 2009 at 3:53 PM, Alli wrote: > > > > > Is it possible to make the extension a wild card somehow, e.g. > > > > > if i want jpg,png,gif,bmp ? > > > > > > > > LiftRules.dispatch.append { > > > > case r @ Req("picture" :: fileName :: Nil, extension, GetRequest) if > > > > List("jpg", "png", "gif").contains(extension) => () => > > > > ... > > > > > > > > } > > > > > > > > Note that this is not a speed-optimal solution (you'd pre-populate > set > > > > with the valid extensions). But it demonstrates using extractors and > > > > guards... the stuff I'm writing about this very day in *Beginning > > > > Scala*. > > > > > > > > Thanks, > > > > David > > > > > > > > > On Jan 27, 11:50 pm, Alli wrote: > > > > > > Thanks chaps, can't believe i didn't spot it :). > > > > > > > > > > > > Cheers, > > > > > > Alfred > > > > > > > > > > > > On Jan 27, 11:48 pm, Tim Perrett wrote: > > > > > > > Change the req to this: > > > > > > > > > > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > > > > > > > > > > That should then work for you > > > > > > > > > > > > > > Cheers, Tim > > > > > > > > > > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > > > LiftRules.dispatch.append { > > > > > > > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) > => > > > > > > > > () => ... > > > > > > > > > > > > > > > > } > > > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
Oh I really wasn't aware of that... I'll take a look at it - I use ehcache for a lot in general, so in that sense it's less if a waste for me :-) Sent from my iPhone On 28 Jan 2009, at 19:35, David Pollak wrote: > IMHO, a third party cache is a huge waste. > > Lift has net.liftweb.util.LRU for this purpose. > > > On Wed, Jan 28, 2009 at 11:33 AM, Joachim A. > wrote: > > Hi, > I'd be interested to have a look at the code :) > I was about to do the same. I'd planned to use a simple cache (by > uuid) in a > concurrent, weak map but EHCache might be the better solution, I > guess. > > Thanks a lot, > Joachim > > > On this note, I wrote an image cache for use in conjunction with > > MappedBinary - if anyone is interested I'm happy to post the code. > It > > uses EHCache and first checks the cache for the right image, and > grabs > > it if it's there, otherwise it does the database read. If your > needing > > to store images in the database, using an object cache can vastly > cut > > the amount of DB access and reduce server load > > > > Cheers > > > > Tim > > > > On Jan 28, 12:00 am, Alli wrote: > > > Thanks, will definitely order a PDF or your book when it's out. > > > > > > Cheers, > > > Alli > > > > > > On Jan 27, 11:56 pm, David Pollak > > > > > > wrote: > > > > On Tue, Jan 27, 2009 at 3:53 PM, Alli > wrote: > > > > > Is it possible to make the extension a wild card somehow, e.g. > > > > > if i want jpg,png,gif,bmp ? > > > > > > > > LiftRules.dispatch.append { > > > > case r @ Req("picture" :: fileName :: Nil, extension, > GetRequest) if > > > > List("jpg", "png", "gif").contains(extension) => () => > > > > ... > > > > > > > > } > > > > > > > > Note that this is not a speed-optimal solution (you'd pre- > populate set > > > > with the valid extensions). But it demonstrates using > extractors and > > > > guards... the stuff I'm writing about this very day in > *Beginning > > > > Scala*. > > > > > > > > Thanks, > > > > David > > > > > > > > > On Jan 27, 11:50 pm, Alli wrote: > > > > > > Thanks chaps, can't believe i didn't spot it :). > > > > > > > > > > > > Cheers, > > > > > > Alfred > > > > > > > > > > > > On Jan 27, 11:48 pm, Tim Perrett > wrote: > > > > > > > Change the req to this: > > > > > > > > > > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > > > > > > > > > > That should then work for you > > > > > > > > > > > > > > Cheers, Tim > > > > > > > > > > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > > > LiftRules.dispatch.append { > > > > > > > > case r @ Req("picture" :: fileName :: Nil, "", > GetRequest) => > > > > > > > > () => ... > > > > > > > > > > > > > > > > } > > > > > > > -- > Lift, the simply functional web framework http://liftweb.net > Beginning Scala http://www.apress.com/book/view/1430219890 > Follow me: http://twitter.com/dpp > Git some: http://github.com/dpp > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
woot! David, that was a great tip, just reduced the LOC and it works just the same - my cache now looks like: object ProductCache extends KeyedCache[List[String], Product](1000, Full(0.75f), (in: List[String]) => Product.find(By(Product.permanent_link, in.last)) ) Then i have a little helper object which just selects the thumbnail or the large image based on a passed parameter. I cant believe i never knew these existed... learn something everday i guess! Cheers Tim On Jan 28, 9:29 pm, Tim Perrett wrote: > Oh I really wasn't aware of that... I'll take a look at it - I use > ehcache for a lot in general, so in that sense it's less if a waste > for me :-) > > Sent from my iPhone > > On 28 Jan 2009, at 19:35, David Pollak > wrote: > > > IMHO, a third party cache is a huge waste. > > > Lift has net.liftweb.util.LRU for this purpose. > > > On Wed, Jan 28, 2009 at 11:33 AM, Joachim A. > > wrote: > > > Hi, > > I'd be interested to have a look at the code :) > > I was about to do the same. I'd planned to use a simple cache (by > > uuid) in a > > concurrent, weak map but EHCache might be the better solution, I > > guess. > > > Thanks a lot, > > Joachim > > > > On this note, I wrote an image cache for use in conjunction with > > > MappedBinary - if anyone is interested I'm happy to post the code. > > It > > > uses EHCache and first checks the cache for the right image, and > > grabs > > > it if it's there, otherwise it does the database read. If your > > needing > > > to store images in the database, using an object cache can vastly > > cut > > > the amount of DB access and reduce server load > > > > Cheers > > > > Tim > > > > On Jan 28, 12:00 am, Alli wrote: > > > > Thanks, will definitely order a PDF or your book when it's out. > > > > > Cheers, > > > > Alli > > > > > On Jan 27, 11:56 pm, David Pollak > > > > > wrote: > > > > > On Tue, Jan 27, 2009 at 3:53 PM, Alli > > wrote: > > > > > > Is it possible to make the extension a wild card somehow, e.g. > > > > > > if i want jpg,png,gif,bmp ? > > > > > > LiftRules.dispatch.append { > > > > > case r @ Req("picture" :: fileName :: Nil, extension, > > GetRequest) if > > > > > List("jpg", "png", "gif").contains(extension) => () => > > > > > ... > > > > > > } > > > > > > Note that this is not a speed-optimal solution (you'd pre- > > populate set > > > > > with the valid extensions). But it demonstrates using > > extractors and > > > > > guards... the stuff I'm writing about this very day in > > *Beginning > > > > > Scala*. > > > > > > Thanks, > > > > > David > > > > > > > On Jan 27, 11:50 pm, Alli wrote: > > > > > > > Thanks chaps, can't believe i didn't spot it :). > > > > > > > > Cheers, > > > > > > > Alfred > > > > > > > > On Jan 27, 11:48 pm, Tim Perrett > > wrote: > > > > > > > > Change the req to this: > > > > > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > > > > > That should then work for you > > > > > > > > > Cheers, Tim > > > > > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > > > > LiftRules.dispatch.append { > > > > > > > > > case r @ Req("picture" :: fileName :: Nil, "", > > GetRequest) => > > > > > > > > > () => ... > > > > > > > > > > } > > > -- > > Lift, the simply functional web frameworkhttp://liftweb.net > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > Follow me:http://twitter.com/dpp > > Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
On Tue, Jan 27, 2009 at 3:39 PM, Alli wrote: > > I wrote a frontend so e.g. localhost:8080/picture/blah.jpg > encapsulates /tmp/blah.jpg and will return an InMemoryResponse() with > blah.jpg as content. > > I have something like the following: > LiftRules.dispatch.append { > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () => > ... > } > > Thing is my partial function is not being called when I do /picture/ > blah.jpg but only gets called on /picture/blah > > It looks like 'fileName' is not allowed to have a 'dot' in it. > > Is it possible that this is a bug? It's by design. The suffix is removed and a separate parameter. Try this: LiftRules.dispatch.append { case r @ Req("picture" :: fileName :: Nil, "jpg", GetRequest) => () => ... } > > > I'm not familiar enough with the Lift code base to dive into the rules > engine. > > Cheers, > Alfred > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.amazon.com/Beginning-Scala-David-Pollak/dp/1430219890/ref=sr_1_1?ie=UTF8&s=books&qid=1233018535&sr=8-1 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
Change the req to this: Req("picture" :: fileName :: Nil, "jpg", GetRequest) That should then work for you Cheers, Tim On Jan 27, 11:39 pm, Alli wrote: > LiftRules.dispatch.append { > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () => > ... > > } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
Thanks chaps, can't believe i didn't spot it :). Cheers, Alfred On Jan 27, 11:48 pm, Tim Perrett wrote: > Change the req to this: > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > That should then work for you > > Cheers, Tim > > On Jan 27, 11:39 pm, Alli wrote: > > > LiftRules.dispatch.append { > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () => > > ... > > > } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
Is it possible to make the extension a wild card somehow, e.g. if i want jpg,png,gif,bmp ? On Jan 27, 11:50 pm, Alli wrote: > Thanks chaps, can't believe i didn't spot it :). > > Cheers, > Alfred > > On Jan 27, 11:48 pm, Tim Perrett wrote: > > > Change the req to this: > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > That should then work for you > > > Cheers, Tim > > > On Jan 27, 11:39 pm, Alli wrote: > > > > LiftRules.dispatch.append { > > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () => > > > ... > > > > } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
On Tue, Jan 27, 2009 at 3:53 PM, Alli wrote: > > Is it possible to make the extension a wild card somehow, e.g. > if i want jpg,png,gif,bmp ? LiftRules.dispatch.append { case r @ Req("picture" :: fileName :: Nil, extension, GetRequest) if List("jpg", "png", "gif").contains(extension) => () => ... } Note that this is not a speed-optimal solution (you'd pre-populate set with the valid extensions). But it demonstrates using extractors and guards... the stuff I'm writing about this very day in *Beginning Scala*. Thanks, David > > On Jan 27, 11:50 pm, Alli wrote: > > Thanks chaps, can't believe i didn't spot it :). > > > > Cheers, > > Alfred > > > > On Jan 27, 11:48 pm, Tim Perrett wrote: > > > > > Change the req to this: > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > That should then work for you > > > > > Cheers, Tim > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > LiftRules.dispatch.append { > > > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () => > > > > ... > > > > > > } > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.amazon.com/Beginning-Scala-David-Pollak/dp/1430219890/ref=sr_1_1?ie=UTF8&s=books&qid=1233018535&sr=8-1 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Potential LiftRules dispatch issue.
Thanks, will definitely order a PDF or your book when it's out. Cheers, Alli On Jan 27, 11:56 pm, David Pollak wrote: > On Tue, Jan 27, 2009 at 3:53 PM, Alli wrote: > > > Is it possible to make the extension a wild card somehow, e.g. > > if i want jpg,png,gif,bmp ? > > LiftRules.dispatch.append { > case r @ Req("picture" :: fileName :: Nil, extension, GetRequest) if > List("jpg", "png", "gif").contains(extension) => () => > ... > > } > > Note that this is not a speed-optimal solution (you'd pre-populate set with > the valid extensions). But it demonstrates using extractors and guards... > the stuff I'm writing about this very day in *Beginning Scala*. > > Thanks, > David > > > > > > > On Jan 27, 11:50 pm, Alli wrote: > > > Thanks chaps, can't believe i didn't spot it :). > > > > Cheers, > > > Alfred > > > > On Jan 27, 11:48 pm, Tim Perrett wrote: > > > > > Change the req to this: > > > > > Req("picture" :: fileName :: Nil, "jpg", GetRequest) > > > > > That should then work for you > > > > > Cheers, Tim > > > > > On Jan 27, 11:39 pm, Alli wrote: > > > > > > LiftRules.dispatch.append { > > > > > case r @ Req("picture" :: fileName :: Nil, "", GetRequest) => () => > > > > > ... > > > > > > } > > -- > Lift, the simply functional web frameworkhttp://liftweb.net > Beginning > Scalahttp://www.amazon.com/Beginning-Scala-David-Pollak/dp/1430219890/ref=... > Follow me:http://twitter.com/dpp > Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---