Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 1&1 Internet AG, Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package net.oneandone.jasmin.cache.util;
public class TestCache extends Cache<StringString> {
    public TestCache(int maxSize) {
    public int valueSize(String value) {
        return value.length();
    protected void entryToString(String keyString valueStringBuilder builder) {
        builder.append(key).append(": ").append(value);
    public String compute(String key) {
        for (int i = 0; i < 100; i++) {
            // some busy wait ... no-op:
            i = i * 1;
        return key;
    public String get(String keythrows IOException {
        String value;
        long started;
        value = lookup(key);
        if (value != null) {
            return value;
        started = System.currentTimeMillis();
        value = compute(key);
        add(keyvaluestarted, System.currentTimeMillis() - started);
        return value;
New to GrepCode? Check out our FAQ X