@@ -31,23 +31,15 @@ use futures::stream::BoxStream;
3131use futures:: stream:: StreamExt ;
3232use futures:: stream:: TryStreamExt ;
3333use mononoke_types:: ChangesetId ;
34- use mononoke_types:: RepositoryId ;
3534use shared_error:: anyhow:: IntoSharedError ;
3635use shared_error:: anyhow:: SharedError ;
37- use stats:: prelude:: * ;
3836
3937use crate :: Bookmarks ;
4038use crate :: log:: BookmarkUpdateReason ;
4139use crate :: subscription:: BookmarksSubscription ;
4240use crate :: transaction:: BookmarkTransaction ;
4341use crate :: transaction:: BookmarkTransactionHook ;
4442
45- define_stats ! {
46- prefix = "mononoke.bookmarks.cache" ;
47- cached_bookmarks_hits: dynamic_timeseries( "{}.hit" , ( repo: String ) ; Rate , Sum ) ,
48- cached_bookmarks_misses: dynamic_timeseries( "{}.miss" , ( repo: String ) ; Rate , Sum ) ,
49- }
50-
5143type CacheData = BTreeMap < BookmarkKey , ( BookmarkKind , ChangesetId ) > ;
5244
5345#[ derive( Clone ) ]
@@ -110,7 +102,6 @@ impl Cache {
110102
111103#[ derive( Clone ) ]
112104pub struct CachedBookmarks {
113- repo_id : RepositoryId ,
114105 cache : Arc < Mutex < Option < Cache > > > ,
115106 bookmarks : Arc < dyn Bookmarks > ,
116107}
@@ -126,9 +117,8 @@ fn ttl() -> Option<Duration> {
126117}
127118
128119impl CachedBookmarks {
129- pub fn new ( bookmarks : Arc < dyn Bookmarks > , repo_id : RepositoryId ) -> Self {
120+ pub fn new ( bookmarks : Arc < dyn Bookmarks > ) -> Self {
130121 Self {
131- repo_id,
132122 bookmarks,
133123 cache : Arc :: new ( Mutex :: new ( None ) ) ,
134124 }
@@ -142,9 +132,7 @@ impl CachedBookmarks {
142132 Some ( ref mut cache) => {
143133 // create new cache if the old one has either expired or failed
144134 let cache_failed = cache. is_failed ( ) ;
145- let mut cache_hit = true ;
146135 if cache. expires <= now || cache_failed {
147- cache_hit = false ;
148136 * cache = Cache :: new (
149137 ctx,
150138 self . bookmarks . clone ( ) ,
@@ -165,12 +153,6 @@ impl CachedBookmarks {
165153 ) ;
166154 }
167155
168- if cache_hit {
169- STATS :: cached_bookmarks_hits. add_value ( 1 , ( self . repo_id . id ( ) . to_string ( ) , ) )
170- } else {
171- STATS :: cached_bookmarks_misses. add_value ( 1 , ( self . repo_id . id ( ) . to_string ( ) , ) )
172- }
173-
174156 cache. clone ( )
175157 }
176158 None => {
@@ -781,12 +763,10 @@ mod tests {
781763 . build ( )
782764 . unwrap ( ) ;
783765 let ctx = CoreContext :: test_mock ( fb) ;
784- let repo_id = RepositoryId :: new ( 0 ) ;
785-
786766 let ( mock, requests) = MockBookmarks :: create ( ) ;
787767 let requests = requests. into_future ( ) ;
788768
789- let bookmarks = CachedBookmarks :: new ( Arc :: new ( mock) , repo_id ) ;
769+ let bookmarks = CachedBookmarks :: new ( Arc :: new ( mock) ) ;
790770
791771 let spawn_query = |prefix : & ' static str , ttl : Option < i64 > , rt : & Runtime | {
792772 let ( sender, receiver) = oneshot:: channel ( ) ;
@@ -983,12 +963,10 @@ mod tests {
983963 . build ( )
984964 . unwrap ( ) ;
985965 let ctx = CoreContext :: test_mock ( fb) ;
986- let repo_id = RepositoryId :: new ( 0 ) ;
987-
988966 let ( mock, requests) = MockBookmarks :: create ( ) ;
989967 let requests = requests. into_future ( ) ;
990968
991- let store = CachedBookmarks :: new ( Arc :: new ( mock) , repo_id ) ;
969+ let store = CachedBookmarks :: new ( Arc :: new ( mock) ) ;
992970
993971 let ( sender, receiver) = oneshot:: channel ( ) ;
994972
0 commit comments