Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^2: OO, Library Configuration and Class Variablesby moot (Chaplain) |
on Jun 23, 2005 at 19:55 UTC ( [id://469493]=note: print w/replies, xml ) | Need Help?? |
The $RemoteURI parameter tells Lookup::Remote which URI to request user information from, given a user-id. It performs this request via LWP. The User class encapsulates information concerning a user (surprise!). To avoid heavy network traffic, user data is cached locally for a time, so when $user->info is requested, the user code first tries Lookup::Local to determine if information is cached locally, and if not then uses Lookup::Remote (I realise these are less than perfect names, but they suffice). It's actually not separated out like that (there is just one Lookup class to perform the actual information collection), but for the purposes of discussion it might help to know that there are potentially two steps to determine user information. The $RemoteURI doesn't relate at all to the User, it is just where information will be pulled from - it's configurable, because one installation of the code may be configured to query server A, while another is configured for server B; and it's a class variable because all instances of the class have to hit the same server, and it seems wasteful to store this per-instance. The nature of this product means that round-robin DNS or other centralised user management is not an option. Some very simplified sample code is shown below, with questionable bits commented.
--
In Section
Seekers of Perl Wisdom
|
|