Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14452

Re: Caching with timed expiry

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Jim Janney <jjanney@shell.xmission.com>
Newsgroups comp.lang.java.programmer
Subject Re: Caching with timed expiry
Date Wed, 09 May 2012 13:14:36 -0600
Organization objurgating the centipede
Lines 31
Message-ID <ydn3979kvz7.fsf@shell.xmission.com> (permalink)
References <joc4c0$2hm$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx04.eternal-september.org; posting-host="PnllQd880uOddfy6hsxHuQ"; logging-data="10824"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+e5rprHAsvkzHFAAnP8fjA"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:DIt2xmVvStmOsRGh+Rd+K7PJcYA= sha1:evKBjOTNUByXhWVxbqsuufcYZNs=
Xref csiph.com comp.lang.java.programmer:14452

Show key headers only | View raw


Sebastian <sebastian@undisclosed.invalid> writes:

> Hello there,
>
> does anyone of a cache / map implementation in which entries
> expire after a fixed time? By which I mean that after a cnfigurable
> delay after an enzry has been caches,it is automatically removed
> from the cache and some clean-up action (perhaps event-triggred)
> can be taken.
>
> My scenario is this: A GUI client searches an LDAP server using
> the virtual list view control. The server requires all requests
> to be made over the same connection. So my middleware component
> will need to check out that connection from a pool and cache it,
> using the ASN1 cookie sent by the client as a key.
>
> Trouble is, if the client never signals that it won't request
> another page (e. g. because it crashes), I need to auto-release
> the LDAP server connection to the connection pool to prevent leakage.
> I thought that a ready-made cache with timed expiry would come in handy.
> If there is no such beast, any ideas for possible approaches?
>
> -- Sebastian

Look at subclassing java.util.LinkedHashMap and overriding the
removeEldestEntry method to check an expiration time.  The removal time
will not be precise (since it's triggered when something else is looked
up) but it may be good enough.

-- 
Jim Janney

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Caching with timed expiry Sebastian <sebastian@undisclosed.invalid> - 2012-05-08 23:48 +0200
  Re: Caching with timed expiry Jim Janney <jjanney@shell.xmission.com> - 2012-05-09 13:14 -0600
    Re: Caching with timed expiry Silvio Bierman <silvio@moc.com> - 2012-05-10 10:09 +0200
      Re: Caching with timed expiry Jim Janney <jjanney@shell.xmission.com> - 2012-05-10 03:48 -0600
        Re: Caching with timed expiry Silvio Bierman <silvio@moc.com> - 2012-05-10 12:56 +0200
      Re: Caching with timed expiry Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-10 06:57 -0300
        Re: Caching with timed expiry Sebastian <sebastian@undisclosed.invalid> - 2012-05-13 23:05 +0200
  Re: Caching with timed expiry Roedy Green <see_website@mindprod.com.invalid> - 2012-05-09 14:43 -0700
    Re: Caching with timed expiry Robert Klemme <shortcutter@googlemail.com> - 2012-05-14 23:47 +0200
    Re: Caching with timed expiry Arne Vajhøj <arne@vajhoej.dk> - 2012-05-20 22:18 -0400
  Re: Caching with timed expiry Paul Cager <paul.cager@googlemail.com> - 2012-05-09 13:09 -0700

csiph-web