Revision 3820ae33
Von Christian Ehringfeld vor fast 9 Jahren hinzugefügt
src/cache.cpp | ||
---|---|---|
return false;
|
||
}
|
||
|
||
void Cache::insert(QSharedPointer<Entity> entity) {
|
||
void Cache::insert(const QSharedPointer<Entity> &entity) {
|
||
if (entity.data() && entity.data()->getId() > -1) {
|
||
this->cache.insert(this->generateKey(entity.data()->getId(), QString(entity.data()->getClassname())),
|
||
entity.toWeakRef());
|
||
}
|
||
}
|
||
|
||
void Cache::remove(QSharedPointer<Entity> entity) {
|
||
void Cache::remove(const QSharedPointer<Entity> &entity) {
|
||
if (entity.data() && entity.data()->getId() > -1) {
|
||
this->remove(entity.data()->getId(), QString(entity.data()->getClassname()));
|
||
}
|
||
... | ... | |
QSharedPointer<Entity> Cache::get(qint64 id, const QString &classname) {
|
||
QString key = this->generateKey(id, classname);
|
||
if (this->contains(key)) {
|
||
return this->cache.value(key).toStrongRef();
|
||
QSharedPointer<Entity> ptr = this->cache.value(key).toStrongRef();
|
||
if (!ptr.data()) {
|
||
this->remove(id, classname);
|
||
}
|
||
return ptr;
|
||
}
|
||
return QSharedPointer<Entity>();
|
||
}
|
Auch abrufbar als: Unified diff
...