@@ -24,27 +24,39 @@ use crate::{
24
24
database:: schema:: feedback:: { Field , Prompt } ,
25
25
prelude:: * ,
26
26
} ;
27
+ #[ cfg( feature = "caching-skytable" ) ]
27
28
use bb8:: ManageConnection ;
29
+ #[ cfg( feature = "caching-skytable" ) ]
28
30
use cached:: IOCachedAsync ;
31
+ #[ cfg( feature = "caching-skytable" ) ]
29
32
use chrono:: Utc ;
30
33
use feedback_fusion_codegen:: dynamic_cache;
34
+
35
+ #[ cfg( feature = "caching-skytable" ) ]
31
36
use serde:: { de:: DeserializeOwned , Serialize } ;
37
+ #[ cfg( feature = "caching-skytable" ) ]
32
38
use skytable:: {
33
39
aio:: TcpConnection ,
34
40
pool:: { ConnectionMgrTcp , ConnectionMgrTls } ,
35
41
query, ClientResult , Pipeline , Query , Response ,
36
42
} ;
43
+
44
+ #[ cfg( feature = "caching-skytable" ) ]
37
45
use std:: {
38
46
fmt:: { Debug , Display } ,
39
47
marker:: PhantomData ,
40
48
ops:: DerefMut ,
41
49
time:: Duration ,
42
50
} ;
51
+ #[ cfg( feature = "caching-skytable" ) ]
43
52
use thiserror:: Error ;
53
+ #[ cfg( feature = "caching-skytable" ) ]
44
54
use tokio:: io:: { AsyncRead , AsyncWrite } ;
55
+ #[ cfg( feature = "caching-skytable" ) ]
45
56
use tracing:: { instrument, Instrument } ;
46
57
47
58
// may publish this as crate or submit as pr for cached
59
+ #[ cfg( feature = "caching-skytable" ) ]
48
60
pub struct SkytableCacheBuilder < ' a , K , V > {
49
61
username : & ' a str ,
50
62
password : & ' a str ,
@@ -57,6 +69,7 @@ pub struct SkytableCacheBuilder<'a, K, V> {
57
69
_phantom : PhantomData < ( K , V ) > ,
58
70
}
59
71
72
+ #[ cfg( feature = "caching-skytable" ) ]
60
73
impl < ' a , K , V > SkytableCacheBuilder < ' a , K , V >
61
74
where
62
75
K : Display ,
@@ -122,6 +135,7 @@ where
122
135
}
123
136
}
124
137
138
+ #[ cfg( feature = "caching-skytable" ) ]
125
139
pub struct SkytableTlsCacheBuilder < ' a , K , V > {
126
140
username : & ' a str ,
127
141
password : & ' a str ,
@@ -135,6 +149,7 @@ pub struct SkytableTlsCacheBuilder<'a, K, V> {
135
149
_phantom : PhantomData < ( K , V ) > ,
136
150
}
137
151
152
+ #[ cfg( feature = "caching-skytable" ) ]
138
153
impl < ' a , K , V > SkytableTlsCacheBuilder < ' a , K , V >
139
154
where
140
155
K : Display ,
@@ -208,6 +223,7 @@ where
208
223
}
209
224
}
210
225
226
+ #[ cfg( feature = "caching-skytable" ) ]
211
227
#[ derive( Error , Debug ) ]
212
228
pub enum SkytableCacheError {
213
229
#[ error( transparent) ]
@@ -218,6 +234,7 @@ pub enum SkytableCacheError {
218
234
PoolError ( String ) ,
219
235
}
220
236
237
+ #[ cfg( feature = "caching-skytable" ) ]
221
238
impl < E > From < bb8:: RunError < E > > for SkytableCacheError
222
239
where
223
240
E : Debug ,
@@ -227,18 +244,22 @@ where
227
244
}
228
245
}
229
246
247
+ #[ cfg( feature = "caching-skytable" ) ]
230
248
#[ derive( Clone , Query , Response ) ]
231
249
struct CachedSkytableValue {
232
250
pub ckey : String ,
233
251
pub cvalue : Vec < u8 > ,
234
252
pub ttl : i64 ,
235
253
}
254
+
255
+ #[ cfg( feature = "caching-skytable" ) ]
236
256
impl CachedSkytableValue {
237
257
fn new ( ckey : String , cvalue : Vec < u8 > , ttl : i64 ) -> Self {
238
258
Self { ckey, cvalue, ttl }
239
259
}
240
260
}
241
261
262
+ #[ cfg( feature = "caching-skytable" ) ]
242
263
pub struct SkytableCache < ' a , C : ManageConnection , K , V > {
243
264
space : & ' a str ,
244
265
model : & ' a str ,
@@ -248,6 +269,7 @@ pub struct SkytableCache<'a, C: ManageConnection, K, V> {
248
269
_phantom : PhantomData < ( K , V ) > ,
249
270
}
250
271
272
+ #[ cfg( feature = "caching-skytable" ) ]
251
273
impl < ' a , C , I , S , K , V > SkytableCache < ' a , C , K , V >
252
274
where
253
275
S : AsyncRead + AsyncWrite + Send + Sync + Unpin ,
@@ -274,6 +296,7 @@ where
274
296
}
275
297
}
276
298
299
+ #[ cfg( feature = "caching-skytable" ) ]
277
300
#[ async_trait:: async_trait]
278
301
impl < ' a , C , I , S , K , V > IOCachedAsync < K , V > for SkytableCache < ' a , C , K , V >
279
302
where
0 commit comments