对象类型的Redis示例

时间:2013-12-23 07:58:19

标签: java

来电者1。

Map<String,List<Order>> map = service.findRestaurant("p2");

此处2。

@Cacheable(value = "CUSTOMERORDER", key = "#customerId" )
public Map<String,List<Order>>findCustomer(String customerId){
    System.out.println("Executing getting method " + ".findCustomer(\"" + customerId + "\")");
    Map<String,List<Order>> map = new HashMap<String,List<Order>>();
    return map;
}

如何重复此操作并获取客户订单?

1 个答案:

答案 0 :(得分:0)

这样做。希望这会对你有所帮助。

Map<String,List<Order>> map = new HashMap<String,List<Order>>();

Map<String,List<Order>> customerOrders = new HashMap<String,List<Order>>();

for (Map.Entry<String,List<Order>> entry:customerOrders.entrySet()){
     if(entry.getKey().equals(customerId)){
           customerOrders.put(entry.getKey(),entry.getValue()); 
     }
}