diff options
author | James Moger <james.moger@gitblit.com> | 2011-11-07 21:18:14 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-11-07 21:18:14 -0500 |
commit | 9275bd77ebc70efeea44bbc9fc3b5723c697a475 (patch) | |
tree | 172ecf60ceef80d859c7588b00073c1503ab6215 | |
parent | 074b4b4599383cd1b9ed1132c7474a5aaf292e78 (diff) | |
download | gitblit-9275bd77ebc70efeea44bbc9fc3b5723c697a475.tar.gz gitblit-9275bd77ebc70efeea44bbc9fc3b5723c697a475.zip |
Moved ObjectCache class
-rw-r--r-- | src/com/gitblit/GitBlit.java | 2 | ||||
-rw-r--r-- | src/com/gitblit/utils/ObjectCache.java (renamed from src/com/gitblit/models/ObjectCache.java) | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 834375b7..8db72af1 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -65,7 +65,6 @@ import com.gitblit.models.FederationModel; import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.Metric;
-import com.gitblit.models.ObjectCache;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
@@ -76,6 +75,7 @@ import com.gitblit.utils.FederationUtils; import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.JsonUtils;
import com.gitblit.utils.MetricUtils;
+import com.gitblit.utils.ObjectCache;
import com.gitblit.utils.StringUtils;
/**
diff --git a/src/com/gitblit/models/ObjectCache.java b/src/com/gitblit/utils/ObjectCache.java index 57494fbc..3bbf4d19 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.Map; 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 class ObjectCache<X> implements Serializable { }
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) {
|