3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, 2010 StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET')) { exit(1); }
22 class Status_network_tag extends Safe_DataObject
25 /* the code below is auto generated do not remove the above tag */
27 public $__table = 'status_network_tag'; // table name
28 public $site_id; // int(4) primary_key not_null
29 public $tag; // varchar(64) primary_key not_null
30 public $created; // datetime() not_null
33 function __construct()
36 global $_DB_DATAOBJECT;
38 $sn = new Status_network();
41 $config['db']['table_'. $this->__table] = $sn->_database;
48 function staticGet($k,$v=null)
50 $i = DB_DataObject::staticGet('Status_network_tag',$k,$v);
52 // Don't use local process cache; if we're fetching multiple
53 // times it's because we're reloading it in a long-running
54 // process; we need a fresh copy!
55 global $_DB_DATAOBJECT;
56 unset($_DB_DATAOBJECT['CACHE']['status_network_tag']);
60 /* the code above is auto generated do not remove the tag below */
66 return Memcached_DataObject::pkeyGet('Status_network_tag', $kv);
70 * Fetch the (possibly cached) tag entries for the given site id.
71 * Uses status_network's cache settings.
73 * @param string $site_id
74 * @return array of strings
76 static function getTags($site_id)
78 $key = 'status_network_tags:' . $site_id;
79 if (Status_network::$cache) {
80 $packed = Status_network::$cache->get($key);
81 if (is_string($packed)) {
85 return explode('|', $packed);
92 $tags = new Status_network_tag();
93 $tags->site_id = $site_id;
95 while ($tags->fetch()) {
96 $result[] = $tags->tag;
100 if (Status_network::$cache) {
101 $packed = implode('|', $result);
102 Status_network::$cache->set($key, $packed, 3600);
109 * Drop the cached tag entries for this site.
110 * Needed after inserting/deleting a tag entry.
114 $key = 'status_network_tags:' . $this->site_id;
115 if (Status_network::$cache) {
116 Status_network::$cache->delete($key);
122 $ret = parent::insert();
129 $ret = parent::delete();