Cascading update cache system

  Kiến thức lập trình

I have the following JavaScript class setup:

class Country {
    id: string;
    data: any;
}

class Firm {
    id: string;
    data: any;
}

class Product {
    id: string;
    country: Country;
    firm: Firm;
}

class CacheManager {
    countries: Country[] = [];
    firms: Firm[] = [];
    products: Product[] = [];

    test() {
        this.countries['country_1'] = {
            id: 'country_1',
            data: {}
        };

        this.firms['firm_1'] = {
            id: 'firm_1',
            data: {}
        };

        this.products['product_1'] = {
            id: 'product_1',
            country: this.countries['country_1'],
            firm: this.firms['firm_1']
        };

        this.countries['country_1'].data = { new_data: true };

        console.log(this.products['product_1']);
    }
}

In this script, updating the country object automatically updates it in the product because JavaScript stores references to objects. When the child object is changed, it reflects in the parent object due to the reference.

Is it possible to achieve similar automatic updates in Redis? If not, how feasible would it be to maintain a service that updates data based on events and provides the updated data on request (a custom caching system)?

Question 2:

Are there in-memory databases that support cascading updates of related objects?

I’m exploring options for in-memory databases that support cascading updates of related objects, similar to how JavaScript handles object references. Specifically, if I have a parent object that contains references to child objects, and if I update a child object, I want the updates to be reflected automatically in the parent object.

Are there in-memory databases or caching systems that support this feature, or would I need to implement custom logic to manage such updates?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT