diff --git a/lib/cache.c b/lib/cache.c
index 9606ce44c22d995d13c6bc82dfd9ebc71cb00f93..0d69cadf59b04cb4a8d4d3801cd788cd4b1c09f8 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -152,7 +152,7 @@ int kr_cache_peek(struct kr_cache_txn *txn, uint8_t tag, const knot_dname_t *nam
 	} else {
 		/* Check if the record is still valid. */
 		uint32_t drift = *timestamp - found->timestamp;
-		if (drift < found->ttl) {
+		if (drift <= found->ttl) {
 			*timestamp = drift;
 			txn->owner->stats.hit += 1;
 			return kr_ok();
@@ -264,7 +264,7 @@ int kr_cache_materialize(knot_rrset_t *dst, const knot_rrset_t *src, uint32_t dr
 	knot_rdata_t *rd = knot_rdataset_at(&src->rrs, 0);
 	knot_rdata_t *rd_dst = NULL;
 	for (uint16_t i = 0; i < src->rrs.rr_count; ++i) {
-		if (knot_rdata_ttl(rd) > drift) {
+		if (knot_rdata_ttl(rd) >= drift) {
 			/* Append record */
 			if (knot_rdataset_add(&dst->rrs, rd, mm) != 0) {
 				knot_rrset_clear(dst, mm);
diff --git a/tests/test_cache.c b/tests/test_cache.c
index a629766a31ba4853fdfc85d134927e0347ef88e4..f72a69a7a4f35c3d1578bcb0c94245428fe07822 100644
--- a/tests/test_cache.c
+++ b/tests/test_cache.c
@@ -360,7 +360,7 @@ static void test_query(void **state)
 /* Test cache read (simulate aged entry) */
 static void test_query_aged(void **state)
 {
-	uint32_t timestamp = CACHE_TIME + CACHE_TTL;
+	uint32_t timestamp = CACHE_TIME + CACHE_TTL + 1;
 	knot_rrset_t cache_rr;
 	knot_rrset_init(&cache_rr, global_rr.owner, global_rr.type, global_rr.rclass);