@@ -44,21 +44,6 @@ impl<'a> MenuCache<'a> {
44
44
}
45
45
}
46
46
47
- impl < ' a > TryFrom < MenuCache < ' a > > for InDbMenuCache {
48
- type Error = crate :: error:: Error ;
49
- fn try_from ( cache : MenuCache < ' a > ) -> Result < Self , Error > {
50
- let mut json = serde_json:: to_string ( & cache. locations ) ?;
51
- let mut compressed = Vec :: with_capacity ( json. len ( ) / 4 ) ;
52
- let mut compress =
53
- async_compression:: tokio:: bufread:: GzipEncoder :: new ( std:: io:: Cursor :: new ( json) ) ;
54
- compress. read_buf ( & mut compressed) ;
55
- Ok ( Self {
56
- cached_at : cache. cached_at ,
57
- data : compressed,
58
- } )
59
- }
60
- }
61
-
62
47
impl < ' a > Default for MenuCache < ' a > {
63
48
fn default ( ) -> Self {
64
49
Self {
@@ -100,7 +85,10 @@ impl<'a> MenuCache<'a> {
100
85
let mut compressed = Vec :: with_capacity ( json. len ( ) / 4 ) ;
101
86
let mut compress =
102
87
async_compression:: tokio:: bufread:: GzipEncoder :: new ( std:: io:: Cursor :: new ( json) ) ;
103
- compress. read_buf ( & mut compressed) . await ;
88
+ compress
89
+ . read_buf ( & mut compressed)
90
+ . await
91
+ . expect ( "This should succeed" ) ;
104
92
InDbMenuCache {
105
93
cached_at : self . cached_at ,
106
94
data : compressed,
@@ -164,6 +152,8 @@ impl<'a> MenuCache<'a> {
164
152
#[ cfg( test) ]
165
153
mod tests {
166
154
155
+ use std:: time:: Instant ;
156
+
167
157
use super :: * ;
168
158
169
159
#[ tokio:: test]
@@ -174,6 +164,8 @@ mod tests {
174
164
#[ tokio:: test]
175
165
async fn test_refresh ( ) {
176
166
let mut mc = MenuCache :: open ( ) . await . unwrap ( ) ;
167
+ let start = Instant :: now ( ) ;
177
168
mc. refresh ( ) . await . unwrap ( ) ;
169
+ println ! ( "{:?}" , start. elapsed( ) ) ;
178
170
}
179
171
}
0 commit comments