Servlet side Cache implementation - need cache (updateable, portable) in Servlet

Hi Guys,
          Any ideas on implementing an updateable cache on a servlet. The problem is
          that
          it must be updateable (I must be able to tell it to update itself whenever a
          welldefined
          event occurs), and it must work in a cluster environment, and I would prefer
          it to
          be J2EE portable.
          I know I can poll from the servlet - but this isn't the most elegant
          approach.
          My servlet needs to do some really fast security/auditing, but I don't want
          it to
          always do something like an EJB lookup. I can quite easily cache what I
          need
          in the hashmap - problem is updateing it and also having it work in a
          clustered
          environ.
          Any other ideas appreciated,
          Jon
          

ejp wrote:
Of course it is. That's how any Map behavesWhen a key has been discarded its entry is effectively removed from the map, so this class behaves somewhat differently than other Map implementations. I meant, the mapping doesnt prevent the key from getting discarded cause it is a weakreference.
No: it's out of your control, but it's within the garbage collector's control. That is the purpose of the class.You aint talking about the situation written in this email. So if it is out of control, your suggestion about weakhashmap isn't gonna work. Out of control in the sense, it doesnt treat a key which was recently accessed any different from anything which wasn't accessed for a long time.
Because by choosing a key that will get garbage-collected at the time of interest to you, you ensure that the WeakHashMap will drop the corresponding value at the same time as the key is GC'd.Not realted to the problem above. Summarily WeakHashmap is no good for the above scenario.

Similar Messages

  • How to use Java NIO to implement disk cache for serialized java objects

    Hi,
    I have a cache (implemented as hahstable etc.) that contains java objects (mostly strings) and swaps objects from runtime memory to the disk and back based on some algorithms. Currently, the reading and writing from the disk is implemented using java.io.* package i.e. fileInputstream and FileOutputStream. Essentially, I serialize the java object and write to the disk and the deserialize and give it back to the Hashtable cache.
    The performance of swapping from disk to memory is kinda slow. I have read that memory mapping would improve the performance.
    My idea is to do the following:
    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBuffer for that but then I have the following questions. I will not store objects in the hashtable anymore.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?
    As you can see, I am beginner in memory mapped io and need help.

    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBufferThis is a good idea, one that I have worked on. It involves quite a bit of manipulation with temporary buffers and a deep working knowledge of object serialization.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?The best way to handle this is do a two-step process, cutting the file into two pieces and gluing it back together where the original one is...
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.It is hard. Wrapping the streams and making the IO work properly is not the challenge however. The hard part comes in hacking the object streams. The object input/output streams use a ClassDescriptor object which only gets written once/ read once. This shouldn't be a problem if you will read/write the entire file at once, but will bring you grief if you want random access to your objects. You will also need an indexing mechanism to support random access.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?I guess it depends on your needs. Do you require random access to objects? NIO provides some performance gains, but mostly for very large amounts of data (>10M in my experience).
    You can always write all your objects into the same file using normal io techniques and you can still generate an index and acheive random access. It might be easier...
    Good luck

  • How to disable cache implementation in 8.1 SP6 for entity beans

    How to disable cache implementation in 8.1 SP6 for entity beans
    In our production environment, we want to disable cache implementation for entity beans. We are using weblogic 8.1 SP6.
    Weblogic cache implementation has been causing many cachefull exceptions so we want that it fetches the data from database everytime instead of cache.

    Check the "max-beans-in-cache" setting in your weblogic-ejb-jar.xml. The cache full exception, means that a new bean could not be created because of this cache being full.
    Nothing to do with fetching from the database directly.
    If you really want direct fetches then do not use beans at all. Consider using direct JDCB/SQL calls (without a entity bean) to fetch huge data.
    Let's again review your application based on the below explanation before making a decision on which configuration change to perform:
    If you truly have many ejbs simultaneously enrolled in transactions, then yes, the cache must be big enough to hold all the instances.
    Your cache must have a max size large enough to handle your peak simultaneous transaction load.
    Also, try to ask the following query to your application developer. Does every user actually have to have more than one bean in the cache ? Are many of these values read-only reference values that are not updated ?
    SOLUTION CHOICE:
    1. If you are testing with more number of users simultaneously, then you will need to increase the "max-beans-in-cache" setting in your weblogic-ejb-jar.xml to match the load.
    2. If you have few users but still seeing a lot of beans, then consult with your application developer and try to ask the above questions (Does every user have more than......) and based on that try to redesign/tune your application to make it an effective Entity bean model.
    3. If you have queries where huge result sets are returned, consider using plain/direct JDB/SQL calls.
    Arun

  • The Best Cache implementation around...

    Hi All,
    Apologies if this may not seem to be the best forum to ask my question. I was studying different cache implementations. Came across Tangosol and JBoss Cache. They seem to be ideal candidates.
    Has anyone had a chance to do a comparison between them? Or is there some other cache impl which is better than either of them?
    Thanks a lot,
    -Vineet

    That is kinda different. Cache in what sence? Every existing application that requires a cache can have its own implementation. Not every application has a unique implementation. For example, JBOSS Cache is only for websites, and while you program within your xml descriptors you tell it cache preferences... But depends what kind of cache you care about.
    Previously on my POS system, I cached the products in a way which I wanted to do it. You just need basic understanding what a cache implementation is, and you can do your own implementation for your unique problem.

  • Implementing Automatic cache purging

    Hi All ,
    I want to implement Automatic cache purging using Event pooling table in obiee..
    i have followed one site, in that they asked me to crated one table in database ... table columns are as follows
    1.update_type
    2.update_date
    3.databasename
    4.catalogname
    5.schemaname
    6.tablename.
    here i am having one doubt .. in my rpd , i am having two tables which are using in 4 catalogs . so.. my doubt is .. how should i came to know the table has come from particular catalog .. then i should i populated the catalog names in backend table ..
    if any one knows please let me know.
    Thanks
    Sree

    Hi,
    The below links should help you
    http://obiee101.blogspot.com/2008/03/obiee-manage-cache-part-1.html
    and
    http://oraclebizint.wordpress.com/2007/12/18/oracle-bi-ee-101332-scheduling-cache-purging/
    To purge the cache automatically you have to set the cache persistent time in the tables present in the physical layer. There you can mention the time after which you want to purge the cache. The steps are provided below:
    1. Double click on the table in the physical layer.
    2. Select the General tab.
    3. Select the Cacheable option.
    4. Select the Cache Persistent time.
    5. Specifiy the time interval when you need the cache to be refreshed.
    You have to do the same for all tables for which you want to purge the cache
    Thanks
    Deva
    Edited by: Devarasu on Sep 28, 2011 2:39 PM

  • Caching at client end using Oracle Cache Implementation

    I would like to know if we could use Oracle' Cache Implementation at the client end [Application server]- if so how do I go abt it & from performance point of view is this better .... Pls get back at the earliest

    Dear All,
    I got this link while googling -
    http://www.ibm.com/developerworks/webservices/library/ws-cach1/
    ................ caching concept is clear now............ but still
    implementation part is not cleared.....
    How, What and Where i need to do changes for this............
    I am using JDK 1.5 and Axis 1.4........
    Regards,
    Santosh Sharma

  • Question on Implementation of Cache.

    hi everybody,
    I would like to ask Java community Can we have something similar to Cache object in .NET available in java.
    i know there is Hashtable collection which can be implemented as Cache. but suppose i have stored 500 objects in Hashtable out of that 100 objects are no longer referred by any programme in that case these objects should get removed from this Hashtable automatically. Currently,as far as i know ,it is not working like that.
    will Sun people or anybody reply ?

    It is possible to track references and respond to their lifecycle events - have a look at java.lang.ref for reference classes. These allow you to bind things to (eg) HashMaps whilst still leaving them eligible for garbage collection. For this requirement, though, I don't think you'd need to go overboard using a ReferenceQueue.
    In fact, there's an implementation called WeakHashMap that does something a bit like this already. Only in reverse.
    Your cache could use normal Objects for keys and get those to refer to WeakReferences which are examined in its get methods to check the Reference for a null referent (and subsequently remove the corresponding mapping). I doubt it would represent much effort to implement something straightforward.
    Hope this helps.

  • Have a  problem with Lightroom 5.4.  Since the program crashed yesterday it won't launch, it comes up with the message "Lightroom encountered an error when reading its preview cache and needs to quit".  "  Lightroom will attempt to fix this problem net ti

    Have a  problem with Lightroom 5.4.  Since the program crashed yesterday it won't launch, it comes up with the message "Lightroom encountered an error when reading its preview cache and needs to quit".  "  Lightroom will attempt to fix this problem next time it launches".  Except that it doesn't, I keep getting the same message and the program closes.  Does anyone know what I  can do to repair it?  Can't back up, can't do anything.

    There are dozens of threads in this forum that describe the fix

  • Lightroom encountered and error when reading from it preview cache and needs to quit

    A power outage caused my Lightroom 5.2 to shut down without closing.  When I powered back up and opened lightroom it gives me an error "Lightroom encountered and error when reading from it preview cache and needs to quit" and then it says it will try to fix it the next time it opens. I have opened it 20 times and it is not fixing it. I removed the program completely and upgraded to 5.5 AND it is still giving me the same error.  Is my catalog corrupt or something? I had it set to automatically load the most currently used catalog, so it is not allowing me to open or start a new catalog either. HELP!!!

    Search the forum, this has been answered many times.

  • I'm unable to open up Lightroom 5, I get this message in a pop up box: "Lightroom encountered an error when reading from it's preview cache and needs to quit" Underneath  that is "Lightroom will attempt to fix this problem the next time when it launches."

    I'm unable to open up Lightroom 5, I get this message in a pop up box: "Lightroom encountered an error when reading from it's preview cache and needs to quit" Underneath  that is "Lightroom will attempt to fix this problem the next time when it launches."  It hasn't, what should I do? Thanks Shawn (Irish Se7en) .

    Can you try to rename (not delete!) the folder named "YOUR_CATALOG_NAME Previews.lrdata" and restart Lightroom?

  • "Lightroom encountered and error when reading from its preview cache and needs to quit"

    I keep receiving this error every time I open LR, "Lightroom encountered and error when reading from its preview cache and needs to quit" and the app won't open. It said LR would try and fix this error next time I opened it but the error remains. I tried uninstalled and installing the app and the error remains.
    Any Ideas here? Is there another app that may be telling it where to look for the cache and it no longer there? I was using a ramdisk for a bit but ditched it. Not sure if that has something to do with it but it seems suspect.
    Your thoughts?
    --Kenny Brandon Wilson

    Talked to Adobe support this morning, this is their response in case anyone else is looking for help. I'm running a Windows 7 box, LR 5.6.
      Gokul: Click on start and type %appdata%, then open roaming folder.
      Edward: ok
      Gokul: Open Adobe folder.
      Gokul: Open Lightroom folder.
      Gokul: Open Lightroom folder> Preferences.
      Edward: ok
      Gokul: Rename Lightroom 5 Preferences.agprefs file as Lightroom 5 Preferences.agprefsOLD.
      Edward: OK
      Gokul: Please check if you can launch Lightroom without any error.
      Edward: it shows me a welcome screen and is asking me to select my country
      Edward: aka, register the software
      Gokul: You can skip and launch it.
      Edward: LR catalog not found
      Gokul: Please select the catalog.
      Edward: my original catalog?
      Gokul: Yes.
      Edward: testing integrity of catalog
      Edward: loaded just fine
      Gokul: Okay.
      Gokul: Please check if you can re-launch it again.
      Edward: yes, it worked!
      Gokul: Excellent!
      Gokul: Since your preferences were corrupted you were facing issue so we renamed the preferences file to reset it.
      Edward: aha....ok
    All of my import/export presets were intact along with develop user presets. I'm happy as a clam for my $10/month!

  • When I attempt to open lightroom I recive this message: [ Lightroom encountered an error whenreading from itspreviw cache and needs to quit.Lightroom will atempt to fix this problem next time it launches.] I did this a few times but no resoulve

    When I attempt to open lightroom I recive this message: [ Lightroom encountered an error whenreading from itspreviw cache and needs to quit.Lightroom will atempt to fix this problem next time it launches.] I did this a few times but no resoulve

    It isn't a file, it's a folder. It will have the same name as your catalog, but will have the extension data. It will be in the same folder along with your catalog. If you need to use the search feature to search for *.lrdata.

  • LR encountered an error when reading from its preview cache and needs to quit.

    I have the 30 day trial version of Lightroom.  I was able to use it for one week, but the past 1.5-2 weeks, it has been locked up and giving this error message.  How do I resolve the problem?  And how do I reset the 30 day free trial?  I would like to have time using the product, before deciding on the annual contract.
    "LR encountered an error when reading from its preview cache and needs to quit.  Lightroom will attempt to fix this problem the next time it launches."
    Thank you.

    Delete the preview cache from the Lightroom folder in your Pictures folder if you used the default placement. It has the extension .lrdata.
    You cannot reset the trial period.

  • I keep receiving this error every time I open LR, "Lightroom encountered and error when reading from its preview cache and needs to quit" and the app won't open. It said LR would try and fix this error next time I opened it but the error remains. I tried

    I keep receiving this error every time I open LR, "Lightroom encountered and error when reading from its preview cache and needs to quit" and the app won't open. It said LR would try and fix this error next time I opened it but the error remains. I tried uninstalled and installing the app and the error remains. I have windows 8. Can anyone please help???

    Use Windows Explorer to open the folder containing your catalog. The normal location is Pictures\Lightroom. Locate a folder with the extension .lrdata and delete that folder. Then you should be able to start Lightroom again, and Lightroom will begin building and new previews folder. Do not delete anything else.

  • It says Lightroom encountered an error when reading from a previous cache and needs to quit. Light room will attempt to to fix the problem the next time it launches.

    how do i fix this. It says Lightroom encountered an error when reading from a previous cache and needs to quit. Light room will attempt to to fix the problem the next time it launches.

    Have a look at this thread.
    Lightroom encountered an error when reading from its preview cache and needs to quit.  Lightroom will attempt to fix this problem the next time it launches"."

Maybe you are looking for