2 Replies Latest reply on Apr 5, 2004 8:46 PM by Bela Ban

    Objects with multiple paths

    Stefan Arentz Newbie

      Is it possible to store the same object multiple time but with different paths? Like /foo/byName and /foo/byId ? My problem is that I need to do lookups on both but i also need to be able to get all cached objects and iterate over them.

      What happens to reference counting in the cache when there are multiple paths leading to the same object?


        • 1. Re: Objects with multiple paths
          cwampler Newbie

          We had the same issue, and what we did was cached a bunch of key matchups along with the object. So we would do something like this:

          cache.put("/foo/byId", Id, Object)

          Then also

          cache.put ("/keylookup", "/foo/byName," + Name, "/foo/byId," + Id)

          That way when it comes lookup time you can first do a keylookup on "/foo/byName," + Name to see if it has another node (In this case "/foo/byId," + Id, then grab that one.

          If you find a better solution please let me know.

          • 2. Re: Objects with multiple paths
            Bela Ban Master

            Why don't you use this ? :

            Person joe;
            TreeCacheAop tree;

            tree.putObject("/aop/joe1", joe);
            tree.putObject("/aop/bela", joe);

            You'll have 2 bindings for the *same* object. References were introduced by Ben in the 1.0 release of JBossCache