class documentation
class AsyncOfflineBuffer: (source)
Constructor: AsyncOfflineBuffer(offline_path, name)
This class handles an offline message buffer.
Each message that should be stored needs to be a dict before it can be appended to the offline buffer file. The buffer will grow indefinitely until it is emptied.
The buffer can be retrieved as a list of dict messages, and the buffer is regarded as empty after that.
Buffer extension will always be .json, regardless of the initial buffer name.
| Method | __init__ |
The class constructor. |
| Method | __len__ |
Return number of buffered messages. |
| Async Method | append |
Append messages to an existing buffer with 'utf-8' encoding. |
| Async Method | retrieve |
Return the content of the current buffer and regard the buffer empty. |
| Instance Variable | buffer |
Keeps track of buffer empty status. |
| Instance Variable | count |
Keep track on number of stored messages. |
| Instance Variable | filename |
Name of offline file. |
| Property | is |
Return buffer empty status. |
Append messages to an existing buffer with 'utf-8' encoding.
If the buffer is regarded as empty, create a new one.
| Parameters | |
msg:dict | Message to buffer. |