Example usage for org.apache.wicket.util.time Duration seconds

List of usage examples for org.apache.wicket.util.time Duration seconds

Introduction

In this page you can find the example usage for org.apache.wicket.util.time Duration seconds.

Prototype

public final double seconds() 

Source Link

Document

Retrieves the number of seconds of the current Duration.

Usage

From source file:com.github.marting.wicket.datastore.memcached.MemcachedDataStore.java

License:Apache License

@Override
public void storeData(final String sessionId, final int pageId, byte[] data) {
    final String key = getKey(sessionId, pageId);
    SortedSet<String> keys = keysPerSession.get(sessionId);
    if (keys == null) {
        keys = new TreeSet<String>();
        SortedSet<String> old = keysPerSession.putIfAbsent(sessionId, keys);
        if (old != null) {
            keys = old;//from   w  ww  .jav a  2 s .c o  m
        }
    }

    Duration expirationTime = settings.getExpirationTime();

    // TODO Improve to follow Memcached protocol.
    // See net.spy.memcached.MemcachedClient.set(java.lang.String, int, java.lang.Object)()
    //      Time timeToExpire = Time.now().add(expirationTime);

    client.set(key, (int) expirationTime.seconds(), data);
    keys.add(key);
    LOG.debug("Stored data for session '{}' and page id '{}'", sessionId, pageId);
}

From source file:org.wicketstuff.lazymodel.PropertyModelComparison.java

License:Apache License

private Duration measureTime(IProvider<IModel<?>> provider) {
    Time start = Time.now();

    for (int i = 0; i < 100000; i++) {
        final IModel<?> m = provider.get();
        for (int j = 0; j < 10; j++) {
            m.getObject();/*from w w  w  .  j  a  v  a 2  s. c o  m*/
        }
    }

    Duration duration = Time.now().subtract(start);

    System.out.println(String.format("PropertyModelComparison %s: %s seconds", provider.get().getClass(),
            duration.seconds()));

    return duration;
}

From source file:wicketbox.AbstractBoxBehavior.java

License:Apache License

/**
 * Persist to a cookie.//from   w w w. j av a  2s  .  c o  m
 * 
 * @param key
 *            key of cookie
 * @param maxAge
 *            maximum age for cookie
 */
public static String persistToCookie(String key, Duration maxAge) {
    return String.format("wicketbox.persistToCookie('%s',%s)", key, maxAge.seconds());
}