@@ -14,11 +14,8 @@ mod utils;
14
14
use std:: path:: Path ;
15
15
16
16
use anyhow:: Result ;
17
- use database:: db_invalidation:: check_db_invalidation_and_cleanup;
18
17
19
- use crate :: database:: {
20
- db_versioning:: handle_db_versioning, noop_kv:: NoopKvDb , turbo:: TurboKeyValueDatabase ,
21
- } ;
18
+ use crate :: database:: { noop_kv:: NoopKvDb , turbo:: TurboKeyValueDatabase } ;
22
19
pub use crate :: {
23
20
backend:: { BackendOptions , StorageMode , TurboTasksBackend } ,
24
21
database:: db_versioning:: GitVersionInfo ,
@@ -47,18 +44,18 @@ pub fn lmdb_backing_storage(
47
44
startup_cache:: StartupCacheLayer ,
48
45
} ;
49
46
50
- check_db_invalidation_and_cleanup ( base_path ) ? ;
51
- let versioned_path = handle_db_versioning ( base_path , version_info ) ? ;
52
- let fresh_db = is_fresh ( & versioned_path ) ;
53
- let database = crate :: database :: lmdb :: LmbdKeyValueDatabase :: new ( & versioned_path) ? ;
54
- let database = FreshDbOptimization :: new ( database , fresh_db ) ;
55
- let database =
56
- StartupCacheLayer :: new ( database, versioned_path . join ( "startup.cache" ) , fresh_db) ? ;
57
- let database = ReadTransactionCache :: new ( database ) ;
58
- Ok ( KeyValueDatabaseBackingStorage :: new (
59
- database,
60
- Some ( base_path . to_owned ( ) ) ,
61
- ) )
47
+ KeyValueDatabaseBackingStorage :: open_versioned_on_disk (
48
+ base_path . to_owned ( ) ,
49
+ version_info ,
50
+ | versioned_path| {
51
+ let fresh_db = is_fresh ( & versioned_path ) ;
52
+ let database = crate :: database :: lmdb :: LmbdKeyValueDatabase :: new ( & versioned_path ) ? ;
53
+ let database = FreshDbOptimization :: new ( database, fresh_db) ;
54
+ let database =
55
+ StartupCacheLayer :: new ( database , versioned_path . join ( "startup.cache" ) , fresh_db ) ? ;
56
+ Ok ( ReadTransactionCache :: new ( database) )
57
+ } ,
58
+ )
62
59
}
63
60
64
61
pub type TurboBackingStorage = KeyValueDatabaseBackingStorage < TurboKeyValueDatabase > ;
@@ -67,19 +64,17 @@ pub fn turbo_backing_storage(
67
64
base_path : & Path ,
68
65
version_info : & GitVersionInfo ,
69
66
) -> Result < TurboBackingStorage > {
70
- check_db_invalidation_and_cleanup ( base_path) ?;
71
- let versioned_path = handle_db_versioning ( base_path, version_info) ?;
72
- let database = TurboKeyValueDatabase :: new ( versioned_path) ?;
73
- Ok ( KeyValueDatabaseBackingStorage :: new (
74
- database,
75
- Some ( base_path. to_owned ( ) ) ,
76
- ) )
67
+ KeyValueDatabaseBackingStorage :: open_versioned_on_disk (
68
+ base_path. to_owned ( ) ,
69
+ version_info,
70
+ |versioned_path| TurboKeyValueDatabase :: new ( versioned_path) ,
71
+ )
77
72
}
78
73
79
74
pub type NoopBackingStorage = KeyValueDatabaseBackingStorage < NoopKvDb > ;
80
75
81
76
pub fn noop_backing_storage ( ) -> NoopBackingStorage {
82
- KeyValueDatabaseBackingStorage :: new ( NoopKvDb , None )
77
+ KeyValueDatabaseBackingStorage :: new_in_memory ( NoopKvDb )
83
78
}
84
79
85
80
#[ cfg( feature = "lmdb" ) ]
0 commit comments