]> granicus.if.org Git - apache/commitdiff
Track cache size as items are added to and removed from the cache
authorBill Stoddard <stoddard@apache.org>
Thu, 7 Mar 2002 19:27:58 +0000 (19:27 +0000)
committerBill Stoddard <stoddard@apache.org>
Thu, 7 Mar 2002 19:27:58 +0000 (19:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93772 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/mod_mem_cache.c

index 86a46059b2975db2b71eddedb05a09b00b37c828..c3f0563f23f249c155494c5fdd08a9c724892684 100644 (file)
@@ -331,6 +331,7 @@ static int create_entity(cache_handle_t *h, request_rec *r,
     if (!tmp_obj) {
         apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), obj);
         sconf->object_cnt++;
+        sconf->cache_size += len;
     }
     if (sconf->lock) {
         apr_thread_mutex_unlock(sconf->lock);
@@ -408,6 +409,7 @@ static int remove_entity(cache_handle_t *h)
         mem_cache_object_t *mobj = (mem_cache_object_t *) obj->vobj;
         apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL);
         sconf->object_cnt--;
+        sconf->cache_size -= mobj->m_len;
         if (mobj->refcount) {
             mobj->cleanup = 1;
         }
@@ -508,6 +510,7 @@ static int remove_url(const char *type, const char *key)
         mem_cache_object_t *mobj = (mem_cache_object_t *) obj->vobj;
         apr_hash_set(sconf->cacheht, key, APR_HASH_KEY_STRING, NULL);
         sconf->object_cnt--;
+        sconf->cache_size -= mobj->m_len;
         if (mobj->refcount) {
             mobj->cleanup = 1;
         }