[Raleigh-talk] Sharing data between modules

Andrew Rankin andrew at eiknet.com
Fri Dec 19 08:02:07 PST 2008


That makes sense, I'll give a cache a try.  Thanks James.

Andrew

On Fri, Dec 19, 2008 at 10:53 AM, James Olin Oden <james.oden at gmail.com> wrote:
> On Fri, Dec 19, 2008 at 10:04 AM, Andrew Rankin <andrew at eiknet.com> wrote:
>> Hi All.
>>
>> I have question about sharing some data between some Perl modules and
>> the best way to accomplish it.
> So rather than use globals, or horrors, a singleton, simply create a
> class whose objectes
> would contain all this information.   You can either:
>
>   1) create it once, and pass it to the constructors of all the other objects.
>   2) Create yet another class that acts as a cache for your objects,
> and then have
>       every object that needs the information pull from the cache
> (only one object would
>       seed the cache).
>
> I use the latter model quite often as away to avoid singleton, because
> almost every singleton
> I've encountered, I've had a need to use two or more of at some
> instance (i.e. seperate distinct objects
> not two references to the same object).
>
> Cache's are very easy to implement.  They can take the strategy of a
> singleton interface to a particular class
> (i.e. there is one and only one object tracked in the cache for a
> particular process), or they can take
> an approach of providing a cache of multiple objects each retrievable
> by a unique key.
>
> Does that make sense or do I need to be more concrete?
>
> Cheers...james
> _______________________________________________
> Raleigh-talk mailing list
> Raleigh-talk at pm.org
> http://mail.pm.org/mailman/listinfo/raleigh-talk
>


More information about the Raleigh-talk mailing list