我正在使用spring数据和缓存。
有没有办法将缓存放在默认的存储库方法(findOne ...)而不重新声明我们创建的界面中的那些方法?
CREATE PROCEDURE [dbo].[SplitMyFunkyText]
@Source nvarchar(MAX)
AS
DECLARE @Results AS TABLE(Part NVARCHAR(255))
DECLARE @I INT = 1
DECLARE @Start INT = 1
WHILE @I > 0
BEGIN
SET @Start = @I
SET @I = CHARINDEX(' ',@Source, 1+CHARINDEX(' ',@Source, 1+CHARINDEX(' ', @Source, @I + 1)))
IF @I > 0
INSERT INTO @Results
SELECT SUBSTRING(@Source, @Start, @I - @Start)
ELSE
INSERT INTO @Results
SELECT SUBSTRING(@Source, @Start, LEN(@Source))
END
SELECT * FROM @Results
GO
答案 0 :(得分:0)
我已经在spring数据存储库中使用了它
@Cacheable(value = "accountIds",sync = true)
default List<AccountDetailDTO> getAccountIds() {
findById();
}
答案 1 :(得分:-2)
您可以实现自己的dao,以获取基本信息:
public interface CachedDAO<T, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {
@Cacheable(value = "cacheValue")
T findOne(ID id);
@Cacheable(value = "cacheValue")
List<T> findAll();
@Cacheable(value = "cacheValue")
Page<T> findAll(Pageable pageable);
//Evict because you want to modify value
@CacheEvict(value = "cacheValue", allEntries = true)
<S extends T> S save(S entity);
//the same with delete
@CacheEvict(value = "cacheValue", allEntries = true)
void delete(ID id);
}
您需要再搜索一下,希望它有所帮助。