## ChamplainCache ChamplainCache — Manages cached tiles |

## Synopsis

                        ChamplainCache;
                        ChamplainCacheClass;
    ChamplainCache*     champlain_cache_dup_default         (void);
    gboolean            champlain_cache_fill_tile           (ChamplainCache *self,
                                                             ChamplainTile *tile);
    guint               champlain_cache_get_size_limit      (ChamplainCache *self);
    void                champlain_cache_purge               (ChamplainCache *self);
    void                champlain_cache_purge_on_idle       (ChamplainCache *self);
    void                champlain_cache_set_size_limit      (ChamplainCache *self,
                                                             guint size_limit);
    gboolean            champlain_cache_tile_is_expired     (ChamplainCache *self,
                                                             ChamplainTile *tile);
    void                champlain_cache_update_tile         (ChamplainCache *self,
                                                             ChamplainTile *tile,
                                                             guint filesize);

## Object Hierarchy

      GObject
       +----ChamplainCache

## Properties

      "size-limit"               guint                 : Read / Write

## Description

ChamplainCache is an object to interogate the cache for previously downloaded tiles. ChamplainCache is a singleton, there should be only one instance shared by all map sources.

Tiles most frequently asked gain in "popularity". This popularity will be taken into account when purging the cache.

Unless you are implementing your own ChamplainMapSource, the only function you should need are champlain_cache_purge and champlain_cache_purge_on_idle.

## Details

### ChamplainCache

    typedef struct _ChamplainCache ChamplainCache;

### ChamplainCacheClass

    typedef struct {
      GObjectClass parent_class;
    } ChamplainCacheClass;

### champlain_cache_dup_default ()

    ChamplainCache*     champlain_cache_dup_default         (void);

Returns : | the ChamplainCache singleton, use g_object_unref when not neeeded anymore.

Since 0.4

### champlain_cache_fill_tile ()

    gboolean            champlain_cache_fill_tile           (ChamplainCache *self,
                                                             ChamplainTile *tile);

Loads data from disk for the given tile

`self` : | the ChamplainCache
`tile` : | the ChamplainTile to fill
Returns : | TRUE if the tile was in cache, false if it needs to be loaded from network

Since 0.4

### champlain_cache_get_size_limit ()

    guint               champlain_cache_get_size_limit      (ChamplainCache *self);

`self` : | the ChamplainCache
Returns : | the cache size limit in bytes

Since 0.4

### champlain_cache_purge ()

    void                champlain_cache_purge               (ChamplainCache *self);

Purge the cache from the less popular tiles until cache's size limit is reached.

`self` : | the ChamplainCache

Since 0.4

### champlain_cache_purge_on_idle ()

    void                champlain_cache_purge_on_idle       (ChamplainCache *self);

Purge the cache from the less popular tiles until cache's size limit is reached. This is a non blocking call as the purge will happen when the application is idle

`self` : | the ChamplainCache

Since 0.4

### champlain_cache_set_size_limit ()

    void                champlain_cache_set_size_limit      (ChamplainCache *self,
                                                             guint size_limit);

Sets the cache size limit in bytes

`self` : | the ChamplainCache
`size_limit` : | the cache limit in bytes

Since 0.4

### champlain_cache_tile_is_expired ()

    gboolean            champlain_cache_tile_is_expired     (ChamplainCache *self,
                                                             ChamplainTile *tile);

`self` : | the ChamplainCache
`tile` : | the ChamplainTile to fill
Returns : | TRUE if the tile should be reloaded from network, FALSE otherwize.

Since 0.4

### champlain_cache_update_tile ()

    void                champlain_cache_update_tile         (ChamplainCache *self,
                                                             ChamplainTile *tile,
                                                             guint filesize);

Update the tile's information in the cache such as Etag and filesize. Also increase the tile's popularity.

`self` : | the ChamplainCache
`tile` : | the ChamplainTile to fill
`filesize` : | the filesize on the disk

Since 0.4

## Property Details

### The `"size-limit"` property

      "size-limit"               guint                 : Read / Write

The cache size limit in bytes.

Note: this new value will not be applied until you call champlain_cache_purge

Allowed values: [1,G_MAXINT]

Default value: 100000000

Since 0.4