6.1. foundations.cache

cache.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module defines caching related classes.

Others:

6.1.1. Module Attributes

foundations.cache.LOGGER

6.1.2. Classes

class foundations.cache.Cache(**kwargs)[source]

Bases: dict

This class defines the cache object and provides various methods to interact with its content.

Usage:

Parameters:**kwargs – Key / Value pairs. ( Key / Value pairs )
addContent(**content)[source]

This method adds given content to the cache.

Usage:

>>> cache = Cache()
>>> cache.addContent(John="Doe", Luke="Skywalker")
True
>>> cache
{'Luke': 'Skywalker', 'John': 'Doe'}
Parameters:**content – Content to add. ( ** )
Returns:Method success. ( Boolean )
removeContent(*keys)[source]

This method removes given content from the cache.

Usage:

>>> cache = Cache()
>>> cache.addContent(John="Doe", Luke="Skywalker")
True
>>> cache.removeContent("Luke", "John")
True
>>> cache
{}                      
Parameters:*keys – Content to remove. ( * )
Returns:Method success. ( Boolean )
getContent(key)[source]

This method gets given content from the cache.

Usage:

>>> cache = Cache()
>>> cache.addContent(John="Doe", Luke="Skywalker")
True
>>> cache.getContent("Luke")
'Skywalker'
Parameters:key – Content to retrieve. ( Object )
Returns:Content. ( Object )
flushContent()[source]

This method flushes the cache content.

Usage:

>>> cache = Cache()
>>> cache.addContent(John="Doe", Luke="Skywalker")
True
>>> cache.flushContent()
True
>>> cache
{}
Returns:Method success. ( Boolean )

Table Of Contents

Previous topic

6. Api

Next topic

6.2. foundations.common

This Page