缓存设计

简介:
/* 
* JBoss, Home of Professional Open Source 
* Copyright 2005, JBoss Inc., and individual contributors as indicated 
* by the @authors tag. See the copyright.txt in the distribution for a 
* full listing of individual contributors. 

* This is free software; you can redistribute it and/or modify it 
* under the terms of the GNU Lesser General Public License as 
* published by the Free Software Foundation; either version 2.1 of 
* the License, or (at your option) any later version. 

* This software is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
* Lesser General Public License for more details. 

* You should have received a copy of the GNU Lesser General Public 
* License along with this software; if not, write to the Free 
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. 
*/ 
package org.jbpm.pvm.internal.repository; 

import java.util.HashMap; 
import java.util.Map; 


/** 
* @author Tom Baeyens 
*/ 
public class RepositoryCacheImpl implements RepositoryCache { 
  
  Map<String, Map<String, Object>> deployments = new HashMap<String, Map<String,Object>>(); 

  public Object get(String deploymentId, String objectName) { 
    Map<String, Object> deploymentObjects = deployments.get(deploymentId); 
    if (deploymentObjects==null) { 
      return null; 
    } 
    return deploymentObjects.get(objectName); 
  } 

  public void set(String deploymentId, Map<String, Object> objects) { 
    if (objects==null) { 
      deployments.put(deploymentId, null); 
    } else { 
      Map<String, Object> deploymentObjects = deployments.get(deploymentId); 
      if (deploymentObjects==null) { 
        deploymentObjects = new HashMap<String, Object>(); 
        deployments.put(deploymentId, deploymentObjects); 
      } 
      for (String objectName: objects.keySet()) { 
        Object object = objects.get(objectName); 
        deploymentObjects.put(objectName, object); 
      } 
    } 
  } 

  public void remove(String deploymentDbid) { 
    if (deployments!=null) { 
      deployments.remove(deploymentDbid); 
    } 
  } 

  public void clear() { 
    deployments = new HashMap<String, Map<String,Object>>(); 
  } 
相关文章
|
缓存 Java Maven
Java 使用LRUmap设计一个简单的缓存场景
Java 使用LRUmap设计一个简单的缓存场景
474 0
Java 使用LRUmap设计一个简单的缓存场景
|
存储 缓存 NoSQL
微服务实践01--微服务管理11--缓存02--分级缓存设计
微服务实践01--微服务管理11--缓存02--分级缓存设计
276 0
微服务实践01--微服务管理11--缓存02--分级缓存设计
|
XML 存储 缓存
设计一个缓存策略,动态缓存热点数据
写在前面,因为我们最近的大作业项目需要用到热点排行这个功能,因为我们是要使用Elasticsearch来存储数据,然后最初设想是在ES中实现这个热点排行的功能,但是经过仔细思考,在我们这个项目中使用ES来做热点排行是一个很蠢的方式,因为我们这只是一个很小的排行,所以最终我们还是使用Redis来实现热点排行
382 1
设计一个缓存策略,动态缓存热点数据
|
缓存 前端开发 大数据
如何设计一个缓存函数
在项目中你有优化过自己写过的代码吗?或者在你的项目中,你有用过哪些技巧优化你的代码,比如常用的函数防抖、节流,或者异步懒加载、惰性加载等。
103 0
如何设计一个缓存函数
|
缓存 Java 数据库连接
第06篇:Mybatis缓存设计
MyBatis 内置了一个强大的事务性查询缓存机制,它可以非常方便地配置和定制。本篇文章,小编将会在最短的时间呢,通过观察源码来深刻了解Mybatis的 一级二级缓存;然后在说如何定制。
126 0
|
存储 缓存 运维
|
缓存 Java 容器
缓存设计【举例:基于session的购物车的设计】
缓存设计【举例:基于session的购物车的设计】
147 0
|
缓存 NoSQL Java
Redis 缓存设计
本文介绍Redis 缓存设计:穿透优化、无底洞优化、雪崩优化、热点key 重建优化
|
缓存 NoSQL Redis
一图看懂redis、缓存的设计
一图看懂redis、缓存的设计
132 0
一图看懂redis、缓存的设计
|
缓存 监控 NoSQL
分布式系统的缓存设计你真的会了吗?
分布式系统的缓存设计你真的会了吗?
109 0