/**
 * Copyright 2016 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * 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 com.palantir.atlasdb.transaction.impl;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

// This class just here for readability and not directly leaking / tying us down to a Guava class in our API
public class TimestampCache {
    final Cache<Long, Long> timestampCache;

    public TimestampCache() {
        timestampCache = CacheBuilder.newBuilder()
                .maximumSize(1_000_000) // up to ~32MB with java Long object bloat
                .build();
    }

    // returns null if not present
    public Long getCommitTimestampIfPresent(Long startTimestamp) {
        return timestampCache.getIfPresent(startTimestamp);
    }

    // Be very careful to only insert timestamps here that are already present in the backing store,
    // effectively using the timestamp table as existing concurrency control for who wins a commit
    public void putAlreadyCommittedTransaction(Long startTimestamp, Long commitTimestamp) {
        timestampCache.put(startTimestamp, commitTimestamp);
    }
}

@@ -715,17 +715,21 @@
 lder;%0A%0A/
-/
+**%0A *
  This cl
@@ -827,16 +827,20 @@
 our API%0A
+ */%0A
 public c
@@ -1037,17 +1037,17 @@
  up to ~
-3
+7
 2MB with
@@ -1112,11 +1112,19 @@
    /
-/ r
+**%0A     * R
 etur
@@ -1146,16 +1146,24 @@
 present%0A
+     */%0A
     publ
@@ -1288,22 +1288,31 @@
 %0A    %7D%0A%0A
+%0A
     /
-/
+**%0A     *
  Be very
@@ -1402,18 +1402,18 @@
 re,%0A    
-//
+ *
  effecti
@@ -1497,16 +1497,24 @@
  commit%0A
+     */%0A
     publ

Update documentation in TimestampCache