本文整理匯總了Java中com.hazelcast.core.IMap.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java IMap.remove方法的具體用法?Java IMap.remove怎麽用?Java IMap.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hazelcast.core.IMap
的用法示例。
在下文中一共展示了IMap.remove方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public static void main(String[] args) {
HazelcastInstance ins = Hazelcast.newHazelcastInstance();
IMap<Integer, String> map = ins.getMap("");
map.addEntryListener(new ListenerExample(), true);//添加自定義監聽器
map.put(1, "Grand Theft Auto");
map.put(1, "Final Fantasy");
map.put(2, "World Of Warcraft");
HazelcastInstance insex = Hazelcast.newHazelcastInstance();
IMap<Integer, String> mapex = insex.getMap("");
System.out.println(mapex.get(1));
System.out.println(mapex.get(2));
mapex.remove(1);
mapex.remove(2);
System.exit(0);
}
示例2: deleteSingleTicket
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Override
public boolean deleteSingleTicket(final String ticketId) {
final String encTicketId = encodeTicketId(ticketId);
final TicketDefinition metadata = this.ticketCatalog.find(ticketId);
final IMap<String, Ticket> map = getTicketMapInstanceByMetadata(metadata);
return map.remove(encTicketId) != null;
}
示例3: applyChange
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@Override
public void applyChange(ConfigChangeRequest configChange) {
if(readOnly){
return;
}
IMap<String,String> config = hazelcastInstance.getMap(mapReference);
for(Map.Entry<String, String> en: configChange.getAddedProperties().entrySet()){
String metaVal = configChange.getAddedProperties().get("_" + en.getKey()+".ttl");
if(metaVal!=null){
try {
long ms = Long.parseLong(metaVal);
config.put(en.getKey(), en.getValue(), ms, TimeUnit.MILLISECONDS);
}catch(Exception e){
LOG.log(Level.WARNING, "Failed to parse TTL in millis: " + metaVal +
" for '"+ en.getKey()+"'", e);
config.put(en.getKey(), en.getValue());
}
}else {
config.put(en.getKey(), en.getValue());
}
}
for(String key: configChange.getRemovedProperties()){
config.remove(key);
}
IList<String> taList = hazelcastInstance.getList("_tamaya.transactions");
taList.add(configChange.getTransactionID());
config.put("_tamaya.transaction.lastId", configChange.getTransactionID(), 1, TimeUnit.DAYS);
config.put("_tamaya.transaction.startedAt", String.valueOf(configChange.getStartedAt()), 1, TimeUnit.DAYS);
config.flush();
refresh();
}
示例4: main
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
public static void main(String[] args) {
HazelcastInstance ins = Hazelcast.newHazelcastInstance();
IMap<Integer, String> imap = ins.getMap("");
imap.addInterceptor(new InterceptorExample());// 添加攔截器
imap.put(1, "Mei");
imap.put(1, "Tracer");
imap.put(1, "D.va");
imap.put(1, "Mercy");
imap.get(1);
imap.remove(1);
System.out.println(imap.get(1));
}
示例5: handleRefreshToken
import com.hazelcast.core.IMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private Map<String, Object> handleRefreshToken(HttpServerExchange exchange, String refreshToken, String scope, Map<String, Object> formMap) throws ApiException {
if(logger.isDebugEnabled()) logger.debug("refreshToken = " + refreshToken + " scope = " + scope);
Client client = authenticateClient(exchange, formMap);
if(client != null) {
// make sure that the refresh token can be found and client_id matches.
IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
RefreshToken token = tokens.remove(refreshToken);
if(token != null) {
String userId = token.getUserId();
String clientId = token.getClientId();
String oldScope = token.getScope();
if(client.getClientId().equals(clientId)) {
IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
User user = users.get(userId);
if(scope == null) {
scope = oldScope; // use the previous scope when access token is generated
} else {
// make sure scope is the same as oldScope or contained in oldScope.
if(!matchScope(scope, oldScope)) {
throw new ApiException(new Status(MISMATCH_SCOPE, scope, oldScope));
}
}
String jwt;
try {
jwt = JwtHelper.getJwt(mockAcClaims(client.getClientId(), scope, userId, user.getUserType().toString(), null));
} catch (Exception e) {
throw new ApiException(new Status(GENERIC_EXCEPTION, e.getMessage()));
}
// generate a new refresh token and associate it with userId and clientId
String newRefreshToken = UUID.randomUUID().toString();
RefreshToken newToken = new RefreshToken();
newToken.setRefreshToken(newRefreshToken);
newToken.setUserId(userId);
newToken.setClientId(client.getClientId());
newToken.setScope(scope);
tokens.put(refreshToken, newToken);
Map<String, Object> resMap = new HashMap<>();
resMap.put("access_token", jwt);
resMap.put("token_type", "bearer");
resMap.put("expires_in", config.getExpiredInMinutes()*60);
resMap.put("refresh_token", newRefreshToken);
return resMap;
} else {
// mismatched client id
throw new ApiException(new Status(MISMATCH_CLIENT_ID, client.getClientId(), clientId));
}
} else {
// refresh token cannot be found.
throw new ApiException(new Status(REFRESH_TOKEN_NOT_FOUND, refreshToken));
}
}
return new HashMap<>(); // return an empty hash map. this is actually not reachable at all.
}