YAPC::NA 2011 • Asheville, NC

Lazyness is a Virtue -- especially for data loading.
By Steven Lembark (‎Lembark‎) from stlouis.pm
Date: Tuesday, 28 June 2011 10:00
Duration: 20 minutes
Target audience: Intermediate
Language:

You can find more information on the speaker's site:


Accessing a database at process startup for static information is common, but can be hard on the database in a production environment. Another bad alternative is re-checking the data status every time it is used. An AUTOLOAD can handle the issue by lazily installing the sub, but makes it impossible to use can.

Lexical variables and a one-shot subtrouine to load them offer a nice, clean, private way to handle lazy data acquisition: put the permanent handler and data structure in lexical variables, and have the subroutine replace itself after the first call.

Attended by: