public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 2/2] server: cache: short-circuit on special max age value 0
Date: Wed,  3 Jun 2026 13:54:42 +0200	[thread overview]
Message-ID: <20260603115442.361184-3-s.sterz@proxmox.com> (raw)
In-Reply-To: <20260603115442.361184-1-s.sterz@proxmox.com>

a max age of 0 means that the cached information is always considered
outdated. instead of reading from the cache first and then checking
the max age parameter, simply return early.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---

Notes:
    note, currently the cache only reads from the tmpfs /run. so the
    speed-up is likely minimal for now. however, once we persist the cache
    further this should help a bit.

 server/src/namespaced_cache.rs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/server/src/namespaced_cache.rs b/server/src/namespaced_cache.rs
index 2f96df41..ccdec92f 100644
--- a/server/src/namespaced_cache.rs
+++ b/server/src/namespaced_cache.rs
@@ -554,6 +554,10 @@ fn get_impl<T: Serialize + DeserializeOwned>(
     // Namespace should already be verified at this point, no point in checking it again.
     ensure_valid_key(key)?;
 
+    if max_age == Some(0) {
+        return Ok(None);
+    }
+
     let path = get_path(base, namespace, key);
 
     Ok(get_from_path(&path, max_age)?.map(|a| a.value))
-- 
2.47.3





      parent reply	other threads:[~2026-06-03 11:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 11:54 [PATCH datacenter-manager 0/2] fix an issue with cached subscription info Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 1/2] server: subscription: always get fresh subscription info on update Shannon Sterz
2026-06-03 11:54 ` Shannon Sterz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260603115442.361184-3-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal