cache_cache.c revision 3d81f57512275ca06a60a9bcbd23c1f8b429fdf2
/* Copyright 2002-2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "apr_general.h"
#include "mod_cache.h"
#include "cache_hash.h"
#include "cache_pqueue.h"
#include "cache_cache.h"
#include <stdlib.h>
#endif
#include <string.h>
#endif
struct cache_cache_t {
int max_entries;
int total_purges;
long queue_clock;
};
{
tmp->current_size = 0;
tmp->total_purges = 0;
tmp->queue_clock = 0;
return tmp;
}
{
cache_pq_free(c->pq);
cache_hash_free(c->ht);
free(c);
}
{
void *e;
if (!e)
return NULL;
return e;
}
{
long old_priority;
long new_priority;
}
{
long priority;
/* FIX: check if priority of bottom item is greater than inserted one */
/* FIX: If ejected is NULL, we'll segfault here */
if (c->queue_clock > priority)
c->queue_clock = priority;
cache_hash_set(c->ht,
NULL);
c->free_entry(ejected);
c->total_purges++;
}
}
{
void *entry;
if (!c)
return NULL;
if (!entry)
return NULL;
return entry;
}
{
if (rc != APR_SUCCESS)
return rc;
c->current_size -= entry_size;
return APR_SUCCESS;
}