コード例 #1
0
 @Override
 public Cache create(final String id) {
   Assert.notEmpty(id, "id");
   if (this.contains(id)) {
     throw new IllegalArgumentException("A cache with name " + id + " already exists");
   }
   Cache c = new MemoryCacheImpl(id);
   this.caches.add(c);
   return c;
 }
コード例 #2
0
 @Override
 public Cache get(final String id) {
   Assert.notEmpty(id, "id");
   for (Cache cache : this.caches) {
     if (((MemoryCacheImpl) cache).getId().equals(id)) {
       return cache;
     }
   }
   return null;
 }
コード例 #3
0
 @Override
 public void remove(final String id) {
   Assert.notEmpty(id, "id");
   Iterator<Cache> iterator = this.caches.iterator();
   while (iterator.hasNext()) {
     Cache cache = iterator.next();
     if (((MemoryCacheImpl) cache).getId().equals(id)) {
       iterator.remove();
       break;
     }
   }
 }
コード例 #4
0
 @Override
 public boolean contains(final String id) {
   Assert.notEmpty(id, "id");
   boolean b = false;
   for (Cache cache : this.caches) {
     if (((MemoryCacheImpl) cache).getId().equals(id)) {
       b = true;
       break;
     }
   }
   return b;
 }