Package com.avaje.ebean.cache

Examples of com.avaje.ebean.cache.ServerCacheStatistics


    contactCache.getStatistics(true);

    Contact c0 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findUnique();

    ServerCacheStatistics stats0 = contactCache.getStatistics(false);

    Contact c1 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findUnique();

    ServerCacheStatistics stats1 = contactCache.getStatistics(false);

    Assert.assertNotNull(c0);
    Assert.assertNotNull(c1);

    Assert.assertEquals(1, stats0.getHitCount());
    Assert.assertEquals(2, stats1.getHitCount());

    c1.setEmail("mychangedemail@what.com");
    Ebean.save(c1);

    Contact c2 = Ebean.find(Contact.class).where().eq("email", "mychangedemail@what.com")
        .findUnique();

    ServerCacheStatistics stats2 = contactCache.getStatistics(false);

    Assert.assertNotNull(c2);
    Assert.assertEquals(c2.getId(), c1.getId());
    Assert.assertEquals(c0.getId(), c1.getId());
    Assert.assertTrue(stats2.getHitCount() > stats1.getHitCount());

  }
View Full Code Here


    // reset the statistics
    countryCache.getStatistics(true);

    Country c0 = Ebean.getReference(Country.class, "NZ");
    ServerCacheStatistics statistics = countryCache.getStatistics(false);
    int hc = statistics.getHitCount();
    Assert.assertEquals(1, hc);
    Assert.assertNotNull(c0);

    // Country c1 = Ebean.getReference(Country.class, "NZ");
    // Assert.assertEquals(2, countryCache.getStatistics(false).getHitCount());
View Full Code Here

    List<Country> countryList1 = Ebean.find(Country.class)
        .setUseQueryCache(true)
        .order().asc("name")
        .findList();
     
    ServerCacheStatistics statistics = cache.getStatistics(false);
    Assert.assertEquals(1, statistics.getSize());
    Assert.assertEquals(1, statistics.getHitCount());
    Assert.assertSame(countryList1, countryList0);
   
    Country nz = Ebean.find(Country.class, "NZ");
    nz.setName("New Zealandia");
    Ebean.save(nz);
   
    statistics = cache.getStatistics(false);
    Assert.assertEquals(0, statistics.getSize());
   
    List<Country> countryList2 = Ebean.find(Country.class)
        .setUseQueryCache(true)
        .order().asc("name")
        .findList();
View Full Code Here

        .setUseCache(true)
        .findUnique();
   
    Assert.assertNotNull(invoice4);
   
    ServerCacheStatistics statistics = beanCache.getStatistics(false);

    Assert.assertEquals(1, statistics.getSize());
    Assert.assertEquals(0, statistics.getHitCount());

    // fetch out of the cache this time
    EInvoice invoice5 = Ebean.find(EInvoice.class)
        .where().idEq(invoice.getId())
        .setUseCache(true)
        .findUnique();

    Assert.assertNotNull(invoice5);
   
    statistics = beanCache.getStatistics(false);
    Assert.assertEquals(1, statistics.getSize());
    Assert.assertEquals(1, statistics.getHitCount());

    billAddress = invoice5.getBillAddress();
   
    Assert.assertNotNull(billAddress);
    Assert.assertEquals("3 Pineapple St", billAddress.getStreet());
View Full Code Here

 
 
 
  public ServerCacheStatistics getStatistics(boolean reset) {

    ServerCacheStatistics s = new ServerCacheStatistics();
    s.setCacheName(name);
    s.setMaxSize(maxSize);

    // these counters won't necessarily be consistent with
    // respect to each other as activity can occur while
    // they are being calculated
    int mc = reset ? missCount.getAndSet(0) : missCount.get();
    int hc = getHitCount(reset);
    int size = size();
   
    s.setSize(size);
    s.setHitCount(hc);
    s.setMissCount(mc);
   
    return s;
  }
View Full Code Here

TOP

Related Classes of com.avaje.ebean.cache.ServerCacheStatistics

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.