Reputation: 391
I'm looking into killing an user active session for my hazelcast cluster.
We have the session map and that appears to have two entries per session
[SESSIONID] mapped to a boolean value and [SESSIONID]::hz::user mapped to our user object
The way I see it to kill a session I have to loop through the map and find the user object, and once that's found remove that entry parse the key and look for the other sessionId mapped to boolean and kill that as well.
Is there an easier way that I'm missing?
Upvotes: 0
Views: 473
Reputation: 416
It is well described in Hazelcast Mastering book : http://hazelcast.org/mastering-hazelcast/ You need to register to read that book. You can use Predicate with :
Imagine that we have a Hazelcast IMap where the key is some ID, the value is a Person object, and we want to retrieve all persons with a given name using the following (and naive) implementation:
public Set<Person> getWithNameNaive(String name){
Set<Person> result = new HashSet<Person>();
for(Person person: personMap.values()){
if(person.name.equals(name)){
result.add(person);
}
}
return result;
Hazelcast way to solve that problem :
public Set<Person> getWithName(String name) {
Predicate namePredicate = equal("name", name);
return (Set<Person>) personMap.values(namePredicate);
}
Upvotes: 2