Results 1 to 10 of 10

Thread: Can I flush a single entry in osCache?

Hybrid View

  1. #1

    Default Can I flush a single entry in osCache?

    it seems that the OsCacheFacade only supports flushing groups, and not specific entries (see the onFlushCache method). After I update a single row in the database, I only want to flush the corresponding entry. And I don't necessarily want to define a group for each entry. And even if I did, I don't think I can, because the cachingModel does not allow this. Of course, I can subclass the facade and provide my own implementation for the onFlushCache method, but I wanted first to verify that I'm not missing something.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2005
    Location
    San Francisco, CA
    Posts
    114

    Default

    The GeneralCacheAdministrator has a flushEntry method. If you are using the OsCacheManagerFactoryBean it returns an instance of the GeneralCacheAdministrator.

  3. #3

    Default I think the whole design is problematic

    After looking some more at the code, I think the problem goes deeper than my original observation. I find this design problematic, for several reasons:

    First, the flush interceptor flushes the whole cache (or group, but it's the same in this case) for every entry that is updated. This is very inefficient, because if I have a cache of 1000 records - all of them will be flushed every time I update any single one of them.

    There is no way to provide a more fine grained flushin behavior, because the key used for the cache is a hash of the method invocation itself, and not the id of the entity being cached. Therefore, the load() and the save() methods, for the same entitiy, will yield two different keys and there is no way for the flushing to be more accuarte than it is now.

    And in any case, the fact that the generated cache key is completely unrelated to the business id of the cached object is, in my opinion, a serious drawback on its own.

    I was initially very glad to find this solution, because caching does seem to be suitable for an AOP-based declarative configuration, but I don't think I will be able to use this after all.

    If any of the SpringModules developers is reading this, I will be happy to hear your toughts on the matter, and please do not be offended by my criticism.

  4. #4
    Join Date
    Jul 2005
    Posts
    156

    Default

    I have exactly the same question with Spring modules v0.4.

    Each entry of my cache caches a Client transfer object returned from a web service method : getClient(ClientId).

    I want to remove one cache entry when I call the methods remove(ClientId) our update(Client) and not the whole cache.

    Since spring modules caching supports only supports flushing groups, I think I can't do this without having to rewrite a lot of code (perhaps I'm missing a point).

    Is there a possible issue, or will the springmodules developing team be going to add support for this feature ?

    Thanks

  5. #5
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    This could accomplished by creating an interceptor that takes a caching model but removes the item from the cache instead of getting the item from the cache. Unfortunately, since invoke is a final method in the interceptor, you can't override it without changing the source. But it shouldn't be hard to do.
    Bill

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Since spring modules caching supports only supports flushing groups, I think I can't do this without having to rewrite a lot of code (perhaps I'm missing a point).

    Is there a possible issue, or will the springmodules developing team be going to add support for this feature ?
    Raise an issue on Spring Modules JIRA please.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #7
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    It already exists as MOD-165. Its currently on the 0.6 roadmap.
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •