method to count notices linking to an URL
This commit is contained in:
parent
6ab46c70f7
commit
d31397bd45
@ -427,6 +427,7 @@ class File extends Memcached_DataObject
|
|||||||
if ($last) {
|
if ($last) {
|
||||||
self::blow('file:notice-ids:%s;last', $this->url);
|
self::blow('file:notice-ids:%s;last', $this->url);
|
||||||
}
|
}
|
||||||
|
self::blow('file:notice-count:%d', $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -489,4 +490,24 @@ class File extends Memcached_DataObject
|
|||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function noticeCount()
|
||||||
|
{
|
||||||
|
$cacheKey = sprintf('file:notice-count:%d', $this->id);
|
||||||
|
|
||||||
|
$count = self::cacheGet($cacheKey);
|
||||||
|
|
||||||
|
if ($count === false) {
|
||||||
|
|
||||||
|
$f2p = new File_to_post();
|
||||||
|
|
||||||
|
$f2p->file_id = $this->id;
|
||||||
|
|
||||||
|
$count = $f2p->count();
|
||||||
|
|
||||||
|
self::cacheSet($cacheKey, $count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user