On Sat, 18 Jan 2020 at 14:15, Sam Ruby <ru...@intertwingly.net> wrote:
>
> On Sat, Jan 18, 2020 at 7:48 AM sebb <seb...@gmail.com> wrote:
> >
> > On Sat, 18 Jan 2020 at 12:39, Sam Ruby <ru...@intertwingly.net> wrote:
> > >
> > > On Fri, Jan 17, 2020 at 5:10 PM sebb <seb...@gmail.com> wrote:
> > > >
> > > > I'm not sure what is the purpose of the weak references when applied
> > > > to instances of the LDAP class.
> > > >
> > > > Why does an instance not use hard references so that they last for the
> > > > life of the instance?
> > >
> > > Passenger applications like the roster tool, the secretary workbench,
> > > and board agenda tool can stay up for hours or even days.  See:
> > > https://whimsy.apache.org/status/passenger
> >
> > I see.
> >
> > > After every request, every hard reference will go away, enabling the
> > > object to be garbage collected.
> >
> > I don't follow.
> >
> > If the hard references go away, then surely the objects can be
> > garbage-collected?
>
> ASF::LDAP is a module.  It only goes away when the process exits.
> Classes that inherit from ASF::LDAP base have a class instance
> variable which contain a collection of instances.

Are you referring the @collection class variable?
If so, then AFAICT the entries are weak references, so don't affect GC.

> Class instance variables go away when the process exits.

Ok, but I still don't understand what you meant by:

"After every request, every hard reference will go away,"

> A common pattern in both CGI scripts and passenger application within
> Whimsy is to fetch everything you might need, ideally within one LDAP
> request.  Maintain a hard reference on that collection, but don't
> necessarily pass those objections around the application.  Methods
> that you call that seek to find instances of those collections will
> resolve to the same instance, by that I mean that
> ASF::Person.find('rubys') will always return the same object, not
> merely another object with the same values for attributes.  So if I've
> already fetched, for example, public_name, it will be returned without
> another round trip to LDAP.

That paragraph I understand.

> > > What this generally means is that a
> > > request will have a consistent view of LDAP, and new requests will get
> > > fresh data.
> >
> > Understood.
> >
> > > - Sam Ruby
>
> - Sam Ruby

Reply via email to