@@ -92,7 +92,7 @@ private void ensureTTLIndex() {
9292 }
9393
9494 private String fetchFromMongo (String key ) {
95- Document doc = mongoCollection .find (new Document ("_id " , key )).first ();
95+ Document doc = mongoCollection .find (new Document ("key " , key )).first ();
9696 if (doc != null ) {
9797 Date expireAt = doc .getDate ("expireAt" );
9898 if (expireAt != null && expireAt .getTime () < System .currentTimeMillis ()) {
@@ -107,11 +107,11 @@ private String fetchFromMongo(String key) {
107107 private void storeInMongo (String key , String value , int ttl ) {
108108 Date now = new Date ();
109109 Date expireAt = new Date (now .getTime () + (ttl * 1000L ));
110- Document doc = new Document ("_id " , key )
110+ Document doc = new Document ("key " , key )
111111 .append ("value" , value )
112112 .append ("updatedAt" , now )
113113 .append ("expireAt" , expireAt );
114- mongoCollection .replaceOne (new Document ("_id " , key ), doc , new ReplaceOptions ().upsert (true ));
114+ mongoCollection .replaceOne (new Document ("key " , key ), doc , new ReplaceOptions ().upsert (true ));
115115 }
116116
117117 private String fetchFromRedis (String key ) {
@@ -171,6 +171,6 @@ private Long deleteFromRedis(String key) {
171171 }
172172
173173 private void deleteFromMongo (String key ) {
174- mongoCollection .deleteOne (new Document ("_id " , key ));
174+ mongoCollection .deleteOne (new Document ("key " , key ));
175175 }
176176}
0 commit comments