PaferaPy Async 0.1
ASGI framework focused on simplicity and efficiency
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
pafera.cache.Cache Class Reference

Simple filesystem cache implementation for storing binary objects. More...

Inheritance diagram for pafera.cache.Cache:

Public Member Functions

def __init__ (self, cachedir='cache', timeout=10, keepcharacters=['_'])
 Creates an instance of the cache. More...
 
def Load (self, path)
 Returns a binary object stored in the system, or an empty string if the object has expired. More...
 
def SanitizePath (self, path)
 Turns path from the application identifier into a name suitable for the file system. More...
 
def Store (self, path, data)
 Stores data as a binary object into the system. More...
 

Public Attributes

 cachedir
 
 keepcharacters
 
 timeout
 

Detailed Description

Simple filesystem cache implementation for storing binary objects.

Simply call cache.Store() to save the object and cache.Load() to get the object back. path identifies the object while timeout determines how long the object will be saved before timeout.

Definition at line 9 of file cache.py.

Constructor & Destructor Documentation

◆ __init__()

def pafera.cache.Cache.__init__ (   self,
  cachedir = 'cache',
  timeout = 10,
  keepcharacters = ['_'] 
)

Creates an instance of the cache.

keepcharacters is used to determine what non-alphanumeric characters
are allowed in the cache filename.

Definition at line 18 of file cache.py.

Member Function Documentation

◆ Load()

def pafera.cache.Cache.Load (   self,
  path 
)

Returns a binary object stored in the system, or an empty string if the object has expired.

path is the identifier for the object wanted.

Definition at line 45 of file cache.py.

◆ SanitizePath()

def pafera.cache.Cache.SanitizePath (   self,
  path 
)

Turns path from the application identifier into a name suitable for the file system.

It will accept all alphanumeric characters or any characters in keepcharacters.

Definition at line 35 of file cache.py.

◆ Store()

def pafera.cache.Cache.Store (   self,
  path,
  data 
)

Stores data as a binary object into the system.

path is the identifier for the object to be later retrieved.

Definition at line 65 of file cache.py.

Member Data Documentation

◆ cachedir

pafera.cache.Cache.cachedir

Definition at line 28 of file cache.py.

◆ keepcharacters

pafera.cache.Cache.keepcharacters

Definition at line 30 of file cache.py.

◆ timeout

pafera.cache.Cache.timeout

Definition at line 29 of file cache.py.


The documentation for this class was generated from the following file: