cache_cache.c revision 587909d32387845b4470c84c025638375c031bca
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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;
}
void cache_free(cache_cache_t *c)
{
cache_pq_free(c->pq);
cache_hash_free(c->ht);
free(c);
}
{
}
{
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* cache_pop(cache_cache_t *c)
{
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;
}