Skip to content

Cach does not updates data after "put" action #262

@ctasci

Description

@ctasci

Hi,
i am using http requests and custom cache objects to handle the caching.
i have a list of customer. if i do a "put" action after i inserted a customer into my db the cache is not updating/it. if i now refresh the site or "removeAll" from my custom cache object it is holding the data.

here's how i create my custom cache-object if (!CacheFactory.get('customerCache')) { customerCache = CacheFactory('customerCache', { maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire }); } else { customerCache = CacheFactory.get('customerCache'); } this is how i do the put action:
`var customerCache = CacheFactory.get('customerCache');

            var deferred = $q.defer();
            $http.post('/Umbraco/Api/CustomerWebApi/publishCustomer', angular.toJson(customer), {
                cache: customerCache
            }).success(function (data) {
                debugger
                if (data.cError.OK == true) {
                    customerCache.put(data.customer.id, data.customer);
                }
                deferred.resolve(data);
            });
            return deferred.promise;`

and here how i get my list:
var customerCache = CacheFactory.get('customerCache'); var deferred = $q.defer(); var start = new Date().getTime(); debugger $http.get('/Umbraco/Api/CustomerWebApi/getAllCustomerByUser', { cache: customerCache }).success(function (data) { console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms'); deferred.resolve(data); }); return deferred.promise;
Why is the new inserted data not (visible) in the cach-object ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions