@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)什么意思??

从hibernate2.1开始ehcache已经作为hibernate的默认缓存方案(二级缓存方案 sessionfactory级别), 在项目中有针对性的使用缓存将对性能的提升右很大的帮助。

  要使用 Ehcache:需要一下步骤

  一,classpath添加相应的jar(ehcache,commons-logging)

  二,然后在hibernate.cfg.xml中配置

<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
 <property name="cache.use_second_level_cache">true</property>
 <property name="cache.use_query_cache">true</property>

  说明:如果没有配置<property name="cache.use_second_level_cache">true</property>(默认false) 将会产生根据单个id查询的情况(产生很多sql)。

  三,为需要缓存的类添加缓存标示:

  使用mapping文件时需要添加node :

  Java代码  

@Entity 
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)

  如果使用使用hibernate annoation是使用@Cache(usage=CacheConcurrencyStrategy.)标签,有5种可选的缓存方案:

  1,CacheConcurrencyStrategy.NONE

  不适用,默认

  2.  CacheConcurrencyStrategy.NONSTRICT_READ_WRITE

  更新不频繁几个小时或更长

  3,CacheConcurrencyStrategy.READ_ONLY

  对于不发生改变的数据使用 [size=large][/size]

  4,CacheConcurrencyStrategy.READ_WRITE


  基于时间戳判定机制,,对于数据同步要求严格的情况,使用频繁

  5,CacheConcurrencyStrategy.TRANSACTIONAL

  运行在jta环境种,基于事务

转载于:https://www.cnblogs.com/cuizhf/p/3519062.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将代码修改为使用MNIST数据集而不是txt文件,你需要进行以下修改: 1. 导入所需的库和模块: ```python import numpy as np import pandas as pd from sklearn.datasets import fetch_openml ``` 2. 加载MNIST数据集: ```python mnist = fetch_openml('mnist_784', version=1, cache=True) ``` 3. 将图像矩阵和标签分别存储为numpy数组: ```python X = mnist.data y = mnist.target ``` 4. 创建一个包含所有数据的Pandas数据框: ```python df = pd.DataFrame(X) df['label'] = y ``` 5. 将数据框保存为CSV文件: ```python df.to_csv(args.save, index=False) ``` 注意,这里我们使用了`args.save`作为保存文件名,这是根据你之前的代码中的`--save`命令行参数来决定的。 除了以上修改,你还需要删除以下代码块,因为MNIST数据集已经包含了图像数据和标签,不需要再读取其他文件: ```python # read train subjects train_subjects = pd.read_csv(os.path.join(data_path, 'train/subject_train.txt'), header=None, names=['subject']) # read test subjects test_subjects = pd.read_csv(os.path.join(data_path, 'test/subject_test.txt'), header=None, names=['subject']) # concat subjects = pd.concat([train_subjects, test_subjects], axis=0) # read train labels train_labels = pd.read_csv(os.path.join(data_path, 'train/y_train.txt'), header=None, names=['label']) # read train labels test_labels = pd.read_csv(os.path.join(data_path, 'test/y_test.txt'), header=None, names=['label']) # labels labels = pd.concat([train_labels, test_labels], axis=0) final_dataframe = pd.concat([subjects, labels], axis=1) data = [] for name in COLUMNS: final_dataframe = pd.concat([final_dataframe, read_txt(name)], axis=1) ``` 这些修改后的代码将直接将MNIST数据集转换为CSV文件,并保存到指定的路径中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值