|
FFmpegfs Fuse Multi Media Filesystem 2.16
|
#include <cache.h>

Classes | |
| class | sqlite_t |
| The sqlite_t class Wrapper for sqlite3 struct to make use of std::shared_ptr. More... | |
| struct | TABLE_COLUMNS |
| Column definition of sql table. More... | |
| struct | TABLE_DEF |
| Definition of sql table. More... | |
Public Types | |
| typedef TABLE_DEF const * | LPCTABLE_DEF |
| Pointer version of TABLE_DEF. More... | |
| typedef TABLE_DEF * | LPTABLE_DEF |
| Pointer to const version of TABLE_DEF. More... | |
| typedef TABLE_COLUMNS const * | LPCTABLE_COLUMNS |
| Pointer version of TABLE_COLUMNS. More... | |
| typedef TABLE_COLUMNS * | LPTABLE_COLUMNS |
| Pointer to const version of TABLE_COLUMNS. More... | |
| typedef std::vector< TABLE_COLUMNS > | TABLECOLUMNS_VEC |
| Table columns array. More... | |
| typedef TABLECOLUMNS_VEC const * | LPCTABLECOLUMNS_VEC |
| Pointer version of TABLECOLUMNS_VEC. More... | |
| typedef TABLECOLUMNS_VEC * | LPTABLECOLUMNS_VEC |
| Pointer to const version of TABLECOLUMNS_VEC. More... | |
Public Member Functions | |
| Cache () | |
| Construct Cache object. More... | |
| virtual | ~Cache () |
| Destruct Cache object. More... | |
| Cache_Entry * | openio (LPVIRTUALFILE virtualfile) |
| Open cache entry. More... | |
| bool | closeio (Cache_Entry **cache_entry, int flags=CACHE_CLOSE_NOOPT) |
| Close a cache entry. More... | |
| bool | load_index () |
| Load cache index from disk. More... | |
| bool | maintenance (size_t predicted_filesize=0) |
| Run disk maintenance. More... | |
| bool | clear () |
| Clear cache: deletes all entries. More... | |
| bool | prune_expired () |
| Prune expired cache entries. More... | |
| bool | prune_cache_size () |
| Prune cache entries to keep cache size within limit. More... | |
| bool | prune_disk_space (size_t predicted_filesize) |
| Prune cache entries to ensure disk space. More... | |
| bool | remove_cachefile (const std::string &filename, const std::string &fileext) |
| Remove a cache file from disk. More... | |
Protected Member Functions | |
| bool | read_info (LPCACHE_INFO cache_info) |
| Read cache file info. More... | |
| bool | write_info (LPCCACHE_INFO cache_info) |
| Write cache file info. More... | |
| bool | delete_info (const std::string &filename, const std::string &desttype) |
| Delete cache file info. More... | |
| Cache_Entry * | create_entry (LPVIRTUALFILE virtualfile, const std::string &desttype) |
| Create cache entry object for a VIRTUALFILE. More... | |
| bool | delete_entry (Cache_Entry **cache_entry, int flags) |
| Delete cache entry object. More... | |
| void | close_index () |
| Close cache index. More... | |
| std::string | expanded_sql (sqlite3_stmt *pStmt) |
| Get expanded SQL string for a statement. More... | |
| bool | prepare_stmts () |
| Prepare all SQL statements. More... | |
| bool | table_exists (const char *table) |
| Check if SQL table exists in database. More... | |
| bool | column_exists (const char *table, const char *column) |
| Check if column exists in SQL table. More... | |
| bool | check_min_version (int *db_version_major, int *db_version_minor) |
| Check the db version if upgrade needed. More... | |
| int | cmp_version (int version_major_l, int version_minor_l, int version_major_r, int version_minor_r) |
| Compare two versions. More... | |
| bool | begin_transaction () |
| Begin a database transactio.n. More... | |
| bool | end_transaction () |
| End a database transaction. More... | |
| bool | rollback_transaction () |
| Rollback a database transaction. More... | |
| bool | create_table_cache_entry (LPCTABLE_DEF table, const TABLECOLUMNS_VEC &columns) |
| Create cache_entry table. More... | |
| bool | upgrade_db (int *db_version_major, int *db_version_minor) |
| Upgrade database from version below 1.95. More... | |
Private Types | |
| typedef std::pair< std::string, std::string > | cache_key_t |
| Filenames and destination types. More... | |
| typedef std::map< cache_key_t, Cache_Entry * > | cache_t |
| Map of cache entries. More... | |
Private Attributes | |
| std::recursive_mutex | m_mutex |
| Access mutex. More... | |
| std::unique_ptr< sqlite_t > | m_cacheidx_db |
| SQLite handle of cache index database. More... | |
| cache_t | m_cache |
| Cache file (memory mapped file) More... | |
Static Private Attributes | |
| static const TABLE_DEF | m_table_cache_entry |
| Definition and indexes of table "cache_entry". More... | |
| static const TABLECOLUMNS_VEC | m_columns_cache_entry |
| Columns of table "cache_entry". More... | |
| static const TABLE_DEF | m_table_version |
| Definition and indexes of table "version". More... | |
| static const TABLECOLUMNS_VEC | m_columns_version |
| Columns of table "version". More... | |
Friends | |
| class | Cache_Entry |
|
private |
|
private |
| typedef TABLE_COLUMNS const* Cache::LPCTABLE_COLUMNS |
Pointer version of TABLE_COLUMNS.
| typedef TABLE_DEF const* Cache::LPCTABLE_DEF |
| typedef TABLECOLUMNS_VEC const* Cache::LPCTABLECOLUMNS_VEC |
| typedef TABLE_COLUMNS* Cache::LPTABLE_COLUMNS |
Pointer to const version of TABLE_COLUMNS.
| typedef TABLE_DEF* Cache::LPTABLE_DEF |
| typedef std::vector<TABLE_COLUMNS> Cache::TABLECOLUMNS_VEC |
|
virtual |
Destruct Cache object.
Definition at line 142 of file cache.cc.
References close_index(), and m_cache.
|
protected |
Begin a database transactio.n.
Definition at line 303 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by load_index().
|
protected |
Check the db version if upgrade needed.
| [out] | db_version_major | - Upon return, contains the major database version. |
| [out] | db_version_minor | - Upon return, contains the minor database version. |
Definition at line 249 of file cache.cc.
References cmp_version(), DB_MIN_VERSION_MAJOR, DB_MIN_VERSION_MINOR, Logging::error(), and m_cacheidx_db.
Referenced by load_index().
| bool Cache::clear | ( | ) |
|
protected |
Close cache index.
Definition at line 1031 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by ~Cache().
| bool Cache::closeio | ( | Cache_Entry ** | cache_entry, |
| int | flags = CACHE_CLOSE_NOOPT |
||
| ) |
Close a cache entry.
If the cache entry is in use will not be deleted.
| [in,out] | cache_entry | - Cache entry object to be closed. |
| [in] | flags | - One of the CACHE_CLOSE_* flags. |
Definition at line 1093 of file cache.cc.
References Logging::trace().
|
protected |
Compare two versions.
| [in] | version_major_l | - Left major version |
| [in] | version_minor_l | - Left minor version |
| [in] | version_major_r | - Right major version |
| [in] | version_minor_r | - Right minor version |
Definition at line 276 of file cache.cc.
Referenced by check_min_version().
|
protected |
Check if column exists in SQL table.
| [in] | table | - name of table |
| [in] | column | - name of column |
Definition at line 218 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by upgrade_db().
|
protected |
Create cache entry object for a VIRTUALFILE.
| [in] | virtualfile | - VIRTUALFILE struct of a file. |
| [in] | desttype | - Destination type (MP4, WEBM etc.). |
|
protected |
Create cache_entry table.
Definition at line 351 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by load_index(), and upgrade_db().
|
protected |
Delete cache entry object.
| [in,out] | cache_entry | - Cache entry object to be closed. |
| [in] | flags | - One of the CACHE_CLOSE_* flags. |
Definition at line 1051 of file cache.cc.
References CACHE_CHECK_BIT, CACHE_CLOSE_FREE, and m_cache.
|
protected |
Delete cache file info.
| [in] | filename | - Source file name. |
| [in] | desttype | - Destination type (MP4, WEBM etc.). |
Definition at line 978 of file cache.cc.
Referenced by Cache_Entry::delete_info().
|
protected |
End a database transaction.
Definition at line 319 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by load_index().
|
protected |
| bool Cache::load_index | ( | ) |
Load cache index from disk.
Definition at line 611 of file cache.cc.
References append_filename(), begin_transaction(), check_min_version(), create_table_cache_entry(), DB_BASE_VERSION_MAJOR, DB_BASE_VERSION_MINOR, DB_MIN_VERSION_MAJOR, DB_MIN_VERSION_MINOR, DB_VERSION_MAJOR, DB_VERSION_MINOR, Logging::debug(), end_transaction(), Logging::error(), m_cacheidx_db, m_columns_cache_entry, m_columns_version, m_table_cache_entry, m_table_version, mktree(), prepare_stmts(), sqlite3_errstr, table_exists(), TOSTRING, transcoder_cache_path(), upgrade_db(), and Logging::warning().
| bool Cache::maintenance | ( | size_t | predicted_filesize = 0 | ) |
| Cache_Entry * Cache::openio | ( | LPVIRTUALFILE | virtualfile | ) |
Open cache entry.
Opens a cache entry and opens the cache file.
| [in] | virtualfile | - VIRTUALFILE struct of a file. |
Definition at line 1075 of file cache.cc.
References VIRTUALFILE::m_destfile, and Logging::trace().
|
protected |
Prepare all SQL statements.
Definition at line 155 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by load_index().
| bool Cache::prune_cache_size | ( | ) |
| bool Cache::prune_disk_space | ( | size_t | predicted_filesize | ) |
| bool Cache::prune_expired | ( | ) |
|
protected |
Read cache file info.
| [in] | cache_info | - Structure with cache info data. |
Definition at line 785 of file cache.cc.
References Logging::error(), CACHE_INFO::m_access_time, CACHE_INFO::m_audiobitrate, CACHE_INFO::m_audiosamplerate, CACHE_INFO::m_averror, m_cacheidx_db, CACHE_INFO::m_creation_time, CACHE_INFO::m_deinterlace, CACHE_INFO::m_destfile, CACHE_INFO::m_desttype, CACHE_INFO::m_duration, CACHE_INFO::m_encoded_filesize, CACHE_INFO::m_errno, CACHE_INFO::m_error, CACHE_INFO::m_file_size, CACHE_INFO::m_file_time, m_mutex, CACHE_INFO::m_predicted_filesize, CACHE_INFO::m_result, CACHE_INFO::m_segment_count, CACHE_INFO::m_video_frame_count, CACHE_INFO::m_videobitrate, CACHE_INFO::m_videoheight, CACHE_INFO::m_videowidth, NONE, and sqlite3_errstr.
Referenced by Cache_Entry::read_info().
| bool Cache::remove_cachefile | ( | const std::string & | filename, |
| const std::string & | fileext | ||
| ) |
|
protected |
Rollback a database transaction.
Definition at line 335 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
|
protected |
Check if SQL table exists in database.
| [in] | table | - name of table |
Definition at line 189 of file cache.cc.
References Logging::error(), and m_cacheidx_db.
Referenced by load_index().
|
protected |
Upgrade database from version below 1.95.
| [out] | db_version_major | - Upon return, contains the new major database version. |
| [out] | db_version_minor | - Upon return, contains the new minor database version. |
Definition at line 391 of file cache.cc.
References column_exists(), create_table_cache_entry(), DB_VERSION_MAJOR, DB_VERSION_MINOR, Logging::debug(), Logging::error(), Logging::info(), m_cacheidx_db, m_columns_cache_entry, m_table_cache_entry, Cache::TABLE_DEF::name, and TOSTRING.
Referenced by load_index().
|
protected |
Write cache file info.
| [in] | cache_info | - Structure with cache info data. |
Definition at line 912 of file cache.cc.
Referenced by Cache_Entry::update_access(), and Cache_Entry::write_info().
|
friend |
|
private |
Cache file (memory mapped file)
Definition at line 382 of file cache.h.
Referenced by delete_entry(), and ~Cache().
|
private |
SQLite handle of cache index database.
Definition at line 380 of file cache.h.
Referenced by begin_transaction(), check_min_version(), close_index(), column_exists(), create_table_cache_entry(), end_transaction(), load_index(), prepare_stmts(), read_info(), rollback_transaction(), table_exists(), and upgrade_db().
|
staticprivate |
Columns of table "cache_entry".
Definition at line 374 of file cache.h.
Referenced by load_index(), and upgrade_db().
|
staticprivate |
Columns of table "version".
Definition at line 376 of file cache.h.
Referenced by load_index().
|
private |
|
staticprivate |
Definition and indexes of table "cache_entry".
Definition at line 373 of file cache.h.
Referenced by load_index(), and upgrade_db().
|
staticprivate |
Definition and indexes of table "version".
Definition at line 375 of file cache.h.
Referenced by load_index().