EBackend.FileCache

g EBackend.FileCache EBackend.FileCache GObject.Object GObject.Object GObject.Object->EBackend.FileCache

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (filename)

add_object (key, value)

clean ()

freeze_changes ()

get_filename ()

get_keys ()

get_object (key)

get_objects ()

remove ()

remove_object (key)

replace_object (key, new_value)

thaw_changes ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

filename

str

r/w/co

The filename of the cache

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class EBackend.FileCache(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

EBackend.FileCacheClass

Contains only private data that should be read and manipulated using the functions below.

classmethod new(filename)
Parameters:

filename (str) – filename where the cache is kept

Returns:

a new EBackend.FileCache

Return type:

EBackend.FileCache

Creates a new EBackend.FileCache object, which implements a cache of objects. Useful for remote backends.

add_object(key, value)
Parameters:
  • key (str) – the hash key of the object to add

  • value (str) – the object to add

Returns:

True if successful, False if key already exists

Return type:

bool

Adds a new key / value entry to self. If an object corresponding to key already exists in self, the function returns False.

clean()
Returns:

True always

Return type:

bool

Clean up the cache’s contents.

freeze_changes()

Disables temporarily all writes to disk for self.

get_filename()
Returns:

The name of the cache.

Return type:

str

Gets the name of the file where the cache is being stored.

get_keys()
Returns:

a list of keys

Return type:

[str]

Returns a list of keys in self. The keys are owned by self and must not be modified or freed. Free the returned list with g_slist_free().

get_object(key)
Parameters:

key (str) – the hash key of the object to find

Returns:

the object corresponding to key

Return type:

str or None

Returns the object corresponding to key. If no such object exists in self, the function returns None.

get_objects()
Returns:

a list of objects

Return type:

[str]

Returns a list of objects in self. The objects are owned by self and must not be modified or freed. Free the returned list with g_slist_free().

remove()
Returns:

True if successful, False if a file error occurred

Return type:

bool

Remove the cache from disk.

remove_object(key)
Parameters:

key (str) – the hash key of the object to remove

Returns:

True if successful, False if key was not found

Return type:

bool

Removes the object corresponding to key from self. If no such object exists in self, the function returns False.

replace_object(key, new_value)
Parameters:
  • key (str) – the hash key of the object to replace

  • new_value (str) – the new object for key

Returns:

True if successful, False if key was not found

Return type:

bool

Replaces the object corresponding to key with new_value. If no such object exists in self, the function returns False.

thaw_changes()

Reverts the affects of EBackend.FileCache.freeze_changes(). Each change to self is once again written to disk.

Property Details

EBackend.FileCache.props.filename
Name:

filename

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The filename of the cache.