1 Reply Latest reply on May 31, 2007 10:05 AM by manik

    Explicit locking?

    aditsu

      I'm using Jboss Cache 1.4.1 SP3 (TreeCache). Is there a way to lock a node explicitly?
      I want to have a process that contains the cache, and other processes connect to it and perform operations. One desired operation would be "get and lock", and another one would be "update and release".

      I saw that the cache does internal locking (with transactions), but I don't know how to handle that in the situation described above. Which process begins and commits the transaction, and how can they work together?

      I also found "acquire" and "release" methods in the Node class, but they seem to be undocumented, they're just "not to be exposed", whatever that means o_O
      The acquire methods have a timeout parameter, but I'm not sure what it means. Is it the time to wait trying to acquire the lock? Or the maximum time to hold the lock? If it's the former, then how can I release locks automatically after a timeout period?

      Thanks
      Adrian

        • 1. Re: Explicit locking?
          manik

          You shouldn't be using the acquire, etc methods. In 2.0.0, these methods are not available in the public API.

          You could use Option.setForceWriteLock() on the invocation.

          Updates will release locks as the call completes (unless run within a transaction, in which case it will release locks when the transaction commits or rolls back).