glance.image_cache.drivers.base module

Base attribute driver class

class glance.image_cache.drivers.base.Driver[source]

Bases: object

clean(stall_time=None)[source]

Dependent on the driver, clean up and destroy any invalid or incomplete cached images

configure()[source]

Configure the driver to use the stored configuration options Any store that needs special configuration should implement this method. If the store was not able to successfully configure itself, it should raise exception.BadDriverConfiguration

delete_all_cached_images()[source]

Removes all cached image files and any attributes about the images and returns the number of cached image files that were deleted.

delete_all_queued_images()[source]

Removes all queued image files and any attributes about the images and returns the number of queued image files that were deleted.

delete_cached_image(image_id)[source]

Removes a specific cached image file and any attributes about the image

Parameters:

image_id – Image ID

delete_queued_image(image_id)[source]

Removes a specific queued image file and any attributes about the image

Parameters:

image_id – Image ID

get_cache_size()[source]

Returns the total size in bytes of the image cache.

get_cached_images()[source]

Returns a list of records about cached images.

The list of records shall be ordered by image ID and shall look like:

[
    {
    'image_id': <IMAGE_ID>,
    'hits': INTEGER,
    'last_modified': ISO_TIMESTAMP,
    'last_accessed': ISO_TIMESTAMP,
    'size': INTEGER
    }, ...
]
get_image_filepath(image_id, cache_status='active')[source]

This crafts an absolute path to a specific entry

Parameters:
  • image_id – Image ID

  • cache_status – Status of the image in the cache

get_image_size(image_id)[source]

Return the size of the image file for an image with supplied identifier.

Parameters:

image_id – Image ID

get_least_recently_accessed()[source]

Return a tuple containing the image_id and size of the least recently accessed cached file, or None if no cached files.

get_queued_images()[source]

Returns a list of image IDs that are in the queue. The list should be sorted by the time the image ID was inserted into the queue.

is_cacheable(image_id)[source]

Returns True if the image with the supplied ID can have its image file cached, False otherwise.

Parameters:

image_id – Image ID

is_cached(image_id)[source]

Returns True if the image with the supplied ID has its image file cached.

Parameters:

image_id – Image ID

is_queued(image_id)[source]

Returns True if the image identifier is in our cache queue.

Parameters:

image_id – Image ID

open_for_read(image_id)[source]

Open and yield file for reading the image file for an image with supplied identifier.

Parameters:

image_id – Image ID

open_for_write(image_id)[source]

Open a file for writing the image file for an image with supplied identifier.

Parameters:

image_id – Image ID

queue_image(image_id)[source]

Puts an image identifier in a queue for caching. Return True on successful add to the queue, False otherwise…

Parameters:

image_id – Image ID

set_paths()[source]

Creates all necessary directories under the base cache directory