File tree Expand file tree Collapse file tree 5 files changed +423
-0
lines changed Expand file tree Collapse file tree 5 files changed +423
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ members = [
5
5
" shed/async_compression" ,
6
6
" shed/async_unit" ,
7
7
" shed/bytes_ext" ,
8
+ " shed/cachelib_stub" ,
8
9
" shed/chrome_trace" ,
9
10
" shed/cloned" ,
10
11
" shed/codegen_includer_proc_macro" ,
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " cachelib"
3
+ edition = " 2018"
4
+ version = " 0.1.0"
5
+ authors = [' Facebook' ]
6
+ license = " GPLv2+"
7
+ include = [" src/**/*.rs" ]
8
+
9
+ [dependencies ]
10
+ futures_ext = { path = " ../futures_ext" }
11
+ abomonation = " 0.7"
12
+ anyhow = " 1.0"
13
+ bytes = { version = " 0.5" , features = [" serde" ] }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This software may be used and distributed according to the terms of the
5
+ * GNU General Public License found in the LICENSE file in the root
6
+ * directory of this source tree.
7
+ */
8
+
9
+ use anyhow:: { Error , Result } ;
10
+ use futures_ext:: BoxFuture ;
11
+
12
+ use crate :: lrucache:: VolatileLruCachePool ;
13
+
14
+ pub fn get_cached_or_fill < T , F > (
15
+ _cache_pool : & VolatileLruCachePool ,
16
+ _cache_key : String ,
17
+ fetch : F ,
18
+ ) -> BoxFuture < Option < T > , Error >
19
+ where
20
+ T : abomonation:: Abomonation + Clone + Send + ' static ,
21
+ F : FnOnce ( ) -> BoxFuture < Option < T > , Error > ,
22
+ {
23
+ fetch ( )
24
+ }
25
+
26
+ pub fn get_cached < T > ( _cache_pool : & VolatileLruCachePool , _cache_key : & String ) -> Result < Option < T > >
27
+ where
28
+ T : abomonation:: Abomonation + Clone + Send + ' static ,
29
+ {
30
+ Ok ( None )
31
+ }
32
+
33
+ /// Returns `false` if the entry could not be inserted (e.g. another entry with the same
34
+ /// key was inserted first)
35
+ pub fn set_cached < T > (
36
+ _cache_pool : & VolatileLruCachePool ,
37
+ _cache_key : & String ,
38
+ _entry : & T ,
39
+ ) -> Result < bool >
40
+ where
41
+ T : abomonation:: Abomonation + Clone + Send + ' static ,
42
+ {
43
+ Ok ( false )
44
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This software may be used and distributed according to the terms of the
5
+ * GNU General Public License found in the LICENSE file in the root
6
+ * directory of this source tree.
7
+ */
8
+
9
+ #![ deny( warnings) ]
10
+
11
+ #[ cfg( not( fbcode_build) ) ]
12
+ mod abomonation_future_cache;
13
+ #[ cfg( not( fbcode_build) ) ]
14
+ mod lrucache;
15
+
16
+ #[ cfg( not( fbcode_build) ) ]
17
+ pub use crate :: abomonation_future_cache:: * ;
18
+ #[ cfg( not( fbcode_build) ) ]
19
+ pub use crate :: lrucache:: * ;
20
+
21
+ // export Abomonation so that users of this crate don't need to add abomination as dependency
22
+ #[ cfg( not( fbcode_build) ) ]
23
+ pub use abomonation:: Abomonation ;
24
+
25
+ #[ cfg( fbcode_build) ]
26
+ pub use cachelib:: * ;
You can’t perform that action at this time.
0 commit comments