Class::Phrasebook Class::Phrasebook 11 of 23 : [PREV] [NEXT]

The Module

  • What if we use the Class::Phrasebook inside another class?
    • will we have memory problems?
  • What if other class objects are constructed, and all of them load the same dictionary using the Class::Phrasebook objects?
    • will we end up with many identical dictionaries loaded into the memory?

Suppose we have a 100 User objects, each constructing a Class::Phrasebook object, which loads a dictionary of error messages in English. That means we have 100 User objects holding 100 Class::Phrasebook objects with 100 English dictionaries loaded.

... or do we?

Well, not exactly.

  • The Class::Phrasebook keeps the loaded dictionaries in a cache.
  • The class manages the cache.
  • Thus only one copy of each dictionary is loaded into the cache.
  • Will delete dictionaries from the cache when no objects refer to it.

© 2003 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/