From 9275bd77ebc70efeea44bbc9fc3b5723c697a475 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Mon, 07 Nov 2011 21:18:14 -0500 Subject: [PATCH] Moved ObjectCache class --- src/com/gitblit/utils/ObjectCache.java | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/gitblit/models/ObjectCache.java b/src/com/gitblit/utils/ObjectCache.java similarity index 84% rename from src/com/gitblit/models/ObjectCache.java rename to src/com/gitblit/utils/ObjectCache.java index 57494fb..3bbf4d1 100644 --- a/src/com/gitblit/models/ObjectCache.java +++ b/src/com/gitblit/utils/ObjectCache.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.gitblit.models; +package com.gitblit.utils; import java.io.Serializable; import java.util.Date; @@ -21,7 +21,10 @@ import java.util.concurrent.ConcurrentHashMap; /** - * Reusable object cache. + * Reusable coarse date-based object cache. The date precision is in + * milliseconds and in fast, concurrent systems this cache is too simplistic. + * However, for the cases where its being used in Gitblit this cache technique + * is just fine. * * @author James Moger * @@ -60,7 +63,10 @@ } public X getObject(String name) { - return cache.get(name).object; + if (cache.containsKey(name)) { + return cache.get(name).object; + } + return null; } public void updateObject(String name, X object) { -- Gitblit v1.9.1