libchamplain Reference Manual: ChamplainFileCache

## ChamplainFileCache ChamplainFileCache — Stores and loads cached tiles from the file system |

## Functions

ChamplainFileCache * | champlain_file_cache_new_full ()
void | champlain_file_cache_set_size_limit ()
guint | champlain_file_cache_get_size_limit ()
const gchar * | champlain_file_cache_get_cache_dir ()
void | champlain_file_cache_purge ()
void | champlain_file_cache_purge_on_idle ()

## Properties

gchar * | cache-dir | Read / Write / Construct Only
guint | size-limit | Read / Write / Construct

## Types and Values

struct | ChamplainFileCache

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── ChamplainMapSource
                ╰── ChamplainTileCache
                    ╰── ChamplainFileCache

## Description

ChamplainFileCache is a cache that stores and retrieves tiles from the file system. Tiles most frequently loaded gain in "popularity". This popularity is taken into account when purging the cache.

## Functions

### champlain_file_cache_new_full ()

    ChamplainFileCache *
    champlain_file_cache_new_full (guint size_limit,
                                   const gchar *cache_dir,
                                   ChamplainRenderer *renderer);

Constructor of ChamplainFileCache.

#### Parameters

size_limit | maximum size of the cache in bytes |
cache_dir | the directory where the cache is created. When cache_dir == NULL, a cache in ~/.cache/champlain is used. | [allow-none]
renderer | the ChamplainRenderer used for tiles rendering |

#### Returns

a constructed ChamplainFileCache

Since 0.8

### champlain_file_cache_set_size_limit ()

    void
    champlain_file_cache_set_size_limit (ChamplainFileCache *file_cache,
                                         guint size_limit);

Sets the cache size limit in bytes.

#### Parameters

file_cache | a ChamplainFileCache |
size_limit | the cache limit in bytes |

Since 0.4

### champlain_file_cache_get_size_limit ()

    guint
    champlain_file_cache_get_size_limit (ChamplainFileCache *file_cache);

Gets the cache size limit in bytes.

#### Parameters

file_cache | a ChamplainFileCache |

#### Returns

size limit

Since 0.4

### champlain_file_cache_get_cache_dir ()

    const gchar *
    champlain_file_cache_get_cache_dir (ChamplainFileCache *file_cache);

Gets the directory where the cache database is stored.

#### Parameters

file_cache | a ChamplainFileCache |

#### Returns

the directory

Since 0.6

### champlain_file_cache_purge ()

    void
    champlain_file_cache_purge (ChamplainFileCache *file_cache);

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

#### Parameters

file_cache | a ChamplainFileCache |

Since 0.4

### champlain_file_cache_purge_on_idle ()

    void
    champlain_file_cache_purge_on_idle (ChamplainFileCache *file_cache);

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

#### Parameters

file_cache | a ChamplainFileCache |

Since 0.4

## Types and Values

### struct ChamplainFileCache

    struct ChamplainFileCache;

The ChamplainFileCache structure contains only private data and should be accessed using the provided API

Since 0.6

## Property Details

### The `“cache-dir”` property

      “cache-dir”                gchar *

The directory where the tile database is stored.

Flags: Read / Write / Construct Only

Default value: NULL

Since 0.6

### The `“size-limit”` property

      “size-limit”               guint

The cache size limit in bytes.

Note: this new value will not be applied until you call `champlain_file_cache_purge()`

Flags: Read / Write / Construct

Allowed values: [1,G_MAXINT]

Default value: 100000000

Since 0.4