Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
25eba018
Commit
25eba018
authored
Apr 13, 2015
by
Hugo Beauzée-Luyssen
Browse files
Folder: Use path as the cache key
parent
6d0b86eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Folder.cpp
View file @
25eba018
...
...
@@ -6,8 +6,19 @@
namespace
policy
{
const
std
::
string
FolderTable
::
Name
=
"Folder"
;
const
std
::
string
FolderTable
::
CacheColumn
=
"
id_folder
"
;
const
std
::
string
FolderTable
::
CacheColumn
=
"
path
"
;
unsigned
int
Folder
::*
const
FolderTable
::
PrimaryKey
=
&
Folder
::
m_id
;
const
FolderCache
::
KeyType
&
FolderCache
::
key
(
const
std
::
shared_ptr
<
Folder
>&
self
)
{
return
self
->
path
();
}
FolderCache
::
KeyType
FolderCache
::
key
(
sqlite3_stmt
*
stmt
)
{
return
Traits
<
FolderCache
::
KeyType
>::
Load
(
stmt
,
1
);
}
}
Folder
::
Folder
(
DBConnection
dbConnection
,
sqlite3_stmt
*
stmt
)
...
...
@@ -25,7 +36,7 @@ Folder::Folder( const std::string& path )
bool
Folder
::
createTable
(
DBConnection
connection
)
{
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
FolderTable
::
Name
+
"("
+
policy
::
FolderTable
::
CacheColumn
+
"
INTEGER PRIMARY KEY AUTOINCREMENT,"
+
"id_folder
INTEGER PRIMARY KEY AUTOINCREMENT,"
"path TEXT UNIQUE ON CONFLICT FAIL"
")"
;
return
SqliteTools
::
executeRequest
(
connection
,
req
);
...
...
src/Folder.h
View file @
25eba018
...
...
@@ -15,11 +15,19 @@ struct FolderTable
static
const
std
::
string
CacheColumn
;
static
unsigned
int
Folder
::*
const
PrimaryKey
;
};
struct
FolderCache
{
using
KeyType
=
std
::
string
;
static
const
KeyType
&
key
(
const
std
::
shared_ptr
<
Folder
>&
self
);
static
KeyType
key
(
sqlite3_stmt
*
stmt
);
};
}
class
Folder
:
public
IFolder
,
public
Cache
<
Folder
,
IFolder
,
policy
::
FolderTable
>
class
Folder
:
public
IFolder
,
public
Cache
<
Folder
,
IFolder
,
policy
::
FolderTable
,
policy
::
FolderCache
>
{
using
_Cache
=
Cache
<
Folder
,
IFolder
,
policy
::
FolderTable
>
;
using
_Cache
=
Cache
<
Folder
,
IFolder
,
policy
::
FolderTable
,
policy
::
FolderCache
>
;
public:
Folder
(
DBConnection
dbConnection
,
sqlite3_stmt
*
stmt
);
...
...
@@ -38,6 +46,6 @@ private:
unsigned
int
m_id
;
std
::
string
m_path
;
friend
class
Cache
<
Folder
,
IFolder
,
policy
::
FolderTable
>
;
friend
_Cache
;
friend
struct
policy
::
FolderTable
;
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment