def get()

in helpers/bq-remote-functions/get-policy-tags/main.py [0:0]


    def get(self, key):
        """Retrieves a cached value from Datastore."""
        key = self.datastore_client.key(self.kind, key)
        entity = self.datastore_client.get(key)

        if entity and 'value' in entity and 'expiration' in entity:
            # Make now timezone-aware (assuming UTC)
            now_aware = datetime.datetime.now(pytz.utc)

            if entity['expiration'] > now_aware:
                return entity['value']
            else:
                # Expired entry, delete it
                self.datastore_client.delete(key)

        return None  # Cache miss or expired entry