Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Removed redundant cache.cache_id column (#1488528)

  • Loading branch information...
commit 83121ece3348bfe09bb1026eace79a74a5ccf2c9 1 parent a025cdd
Aleksander Machniak authored
1  CHANGELOG
... ...
@@ -1,6 +1,7 @@
1 1
 CHANGELOG Roundcube Webmail
2 2
 ===========================
3 3
 
  4
+- Removed redundant cache.cache_id column (#1488528)
4 5
 - Fix order of attachments in sent mail (#1488423)
5 6
 - Don't show product version on login screen (can be enabled by config)
6 7
 - Renamed old default skin to 'classic'. Larry is the new default skin.
8  SQL/mssql.initial.sql
... ...
@@ -1,5 +1,4 @@
1 1
 CREATE TABLE [dbo].[cache] (
2  
-	[cache_id] [int] IDENTITY (1, 1) NOT NULL ,
3 2
 	[user_id] [int] NOT NULL ,
4 3
 	[cache_key] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
5 4
 	[created] [datetime] NOT NULL ,
@@ -117,13 +116,6 @@ CREATE TABLE [dbo].[searches] (
117 116
 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
118 117
 GO
119 118
 
120  
-ALTER TABLE [dbo].[cache] WITH NOCHECK ADD 
121  
-	 PRIMARY KEY  CLUSTERED 
122  
-	(
123  
-		[cache_id]
124  
-	)  ON [PRIMARY] 
125  
-GO
126  
-
127 119
 ALTER TABLE [dbo].[cache_index] WITH NOCHECK ADD 
128 120
 	 PRIMARY KEY CLUSTERED 
129 121
 	(
4  SQL/mysql.initial.sql
@@ -36,12 +36,10 @@ CREATE TABLE `users` (
36 36
 -- Table structure for table `cache`
37 37
 
38 38
 CREATE TABLE `cache` (
39  
- `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  39
+ `user_id` int(10) UNSIGNED NOT NULL,
40 40
  `cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL ,
41 41
  `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
42 42
  `data` longtext NOT NULL,
43  
- `user_id` int(10) UNSIGNED NOT NULL,
44  
- PRIMARY KEY(`cache_id`),
45 43
  CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
46 44
    REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
47 45
  INDEX `created_index` (`created`),
4  SQL/mysql.update.sql
@@ -239,3 +239,7 @@ ALTER TABLE `identities` ALTER `user_id` DROP DEFAULT;
239 239
 ALTER TABLE `searches` ALTER `user_id` DROP DEFAULT;
240 240
 
241 241
 /*!40014 SET FOREIGN_KEY_CHECKS=1 */;
  242
+
  243
+-- Updates from version 0.8
  244
+
  245
+ALTER TABLE cache DROP COLUMN cache_id;
12  SQL/postgres.initial.sql
@@ -160,23 +160,11 @@ CREATE TABLE contactgroupmembers (
160 160
 CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
161 161
 
162 162
 --
163  
--- Sequence "cache_ids"
164  
--- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
165  
---
166  
-
167  
-CREATE SEQUENCE cache_ids
168  
-    INCREMENT BY 1
169  
-    NO MAXVALUE
170  
-    NO MINVALUE
171  
-    CACHE 1;
172  
-
173  
---
174 163
 -- Table "cache"
175 164
 -- Name: cache; Type: TABLE; Schema: public; Owner: postgres
176 165
 --
177 166
 
178 167
 CREATE TABLE "cache" (
179  
-    cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
180 168
     user_id integer NOT NULL
181 169
     	REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
182 170
     cache_key varchar(128) DEFAULT '' NOT NULL,
5  SQL/postgres.update.sql
@@ -175,3 +175,8 @@ ALTER TABLE "session" ALTER sess_id TYPE varchar(128);
175 175
 DROP INDEX contacts_user_id_idx;
176 176
 CREATE INDEX contacts_user_id_idx ON contacts USING btree (user_id, del);
177 177
 ALTER TABLE contacts ALTER email TYPE text;
  178
+
  179
+-- Updates from version 0.8
  180
+
  181
+ALTER TABLE cache DROP COLUMN cache_id;
  182
+DROP SEQUENCE cache_ids;
1  SQL/sqlite.initial.sql
@@ -5,7 +5,6 @@
5 5
 -- 
6 6
 
7 7
 CREATE TABLE cache (
8  
-  cache_id integer NOT NULL PRIMARY KEY,
9 8
   user_id integer NOT NULL default 0,
10 9
   cache_key varchar(128) NOT NULL default '',
11 10
   created datetime NOT NULL default '0000-00-00 00:00:00',
13  SQL/sqlite.update.sql
@@ -333,3 +333,16 @@ INSERT INTO contacts (contact_id, user_id, changed, del, name, email, firstname,
333 333
 
334 334
 CREATE INDEX ix_contacts_user_id ON contacts(user_id, del);
335 335
 DROP TABLE contacts_tmp;
  336
+
  337
+-- Updates from version 0.8
  338
+
  339
+DROP TABLE cache;
  340
+CREATE TABLE cache (
  341
+  user_id integer NOT NULL default 0,
  342
+  cache_key varchar(128) NOT NULL default '',
  343
+  created datetime NOT NULL default '0000-00-00 00:00:00',
  344
+  data text NOT NULL
  345
+);
  346
+
  347
+CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key);
  348
+CREATE INDEX ix_cache_created ON cache(created);
12  program/include/rcube_cache.php
@@ -45,7 +45,6 @@ class rcube_cache
45 45
     private $packed;
46 46
     private $index;
47 47
     private $cache         = array();
48  
-    private $cache_keys    = array();
49 48
     private $cache_changes = array();
50 49
     private $cache_sums    = array();
51 50
 
@@ -167,7 +166,7 @@ function remove($key=null, $prefix_mode=false)
167 166
             $this->cache         = array();
168 167
             $this->cache_changed = false;
169 168
             $this->cache_changes = array();
170  
-            $this->cache_keys    = array();
  169
+            $this->cache_sums    = array();
171 170
         }
172 171
         // Remove keys by name prefix
173 172
         else if ($prefix_mode) {
@@ -175,7 +174,7 @@ function remove($key=null, $prefix_mode=false)
175 174
                 if (strpos($k, $key) === 0) {
176 175
                     $this->cache[$k] = null;
177 176
                     $this->cache_changes[$k] = false;
178  
-                    unset($this->cache_keys[$k]);
  177
+                    unset($this->cache_sums[$k]);
179 178
                 }
180 179
             }
181 180
         }
@@ -183,7 +182,7 @@ function remove($key=null, $prefix_mode=false)
183 182
         else {
184 183
             $this->cache[$key] = null;
185 184
             $this->cache_changes[$key] = false;
186  
-            unset($this->cache_keys[$key]);
  185
+            unset($this->cache_sums[$key]);
187 186
         }
188 187
 
189 188
         // Remove record(s) from the backend
@@ -274,7 +273,7 @@ private function read_record($key, $nostore=false)
274 273
         }
275 274
         else {
276 275
             $sql_result = $this->db->limitquery(
277  
-                "SELECT cache_id, data, cache_key".
  276
+                "SELECT data, cache_key".
278 277
                 " FROM ".$this->db->table_name('cache').
279 278
                 " WHERE user_id = ?".
280 279
                 " AND cache_key = ?".
@@ -296,7 +295,6 @@ private function read_record($key, $nostore=false)
296 295
 
297 296
                 $this->cache[$key]      = $data;
298 297
 	            $this->cache_sums[$key] = $md5sum;
299  
-                $this->cache_keys[$key] = $sql_arr['cache_id'];
300 298
             }
301 299
             else {
302 300
                 $this->cache[$key] = null;
@@ -325,7 +323,7 @@ private function write_record($key, $data)
325 323
             return $this->add_record($this->ckey($key), $data);
326 324
         }
327 325
 
328  
-        $key_exists = $this->cache_keys[$key];
  326
+        $key_exists = array_key_exists($key, $this->cache_sums);
329 327
         $key        = $this->prefix . '.' . $key;
330 328
 
331 329
         // Remove NULL rows (here we don't need to check if the record exist)

0 notes on commit 83121ec

Please sign in to comment.
Something went wrong with that request. Please try again.