Skip to content

Commit 2baeca6

Browse files
authored
Merge pull request #182 from peter-wangxu/fix_dbsize
Add `shrink_disk_usage` for sqlite3 base queues
2 parents 464a820 + 7505872 commit 2baeca6

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ Close the console, and then recreate the queue:
180180
'str2'
181181
>>>
182182
183+
New functions:
184+
*Available since v0.8.0*
185+
186+
- ``shrink_disk_usage`` perform a ``VACUUM`` against the sqlite, and rebuild the database file, this usually takes long time and frees a lot of disk space after ``get()``
187+
183188

184189
Example usage of SQLite3 based ``UniqueQ``
185190
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

persistqueue/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding=utf-8
22
__author__ = 'Peter Wang'
33
__license__ = 'BSD'
4-
__version__ = '0.8.0-alpha0'
4+
__version__ = '0.8.0-beta0'
55

66
from .exceptions import Empty, Full # noqa
77
from .queue import Queue # noqa

persistqueue/sqlackqueue.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ def clear_acked_data(
167167
)
168168
return sql, AckStatus.acked
169169

170-
@sqlbase.with_conditional_transaction
171-
def shrink_disk_usage(self):
172-
sql = """VACUUM"""
173-
return sql, ()
174-
175170
@property
176171
def _sql_mark_ack_status(self):
177172
return self._SQL_MARK_ACK_UPDATE.format(

persistqueue/sqlbase.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ def queue(self):
212212
datarows.append(item)
213213
return datarows
214214

215+
@with_conditional_transaction
216+
def shrink_disk_usage(self):
217+
sql = """VACUUM"""
218+
return sql, ()
219+
215220
@property
216221
def size(self):
217222
return self.total

persistqueue/tests/test_sqlackqueue.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def test_open_close_1000(self):
7575
# assert adding another one still works
7676
q.put('foobar')
7777
data = q.get()
78+
q.shrink_disk_usage()
7879
self.assertEqual('foobar', data)
7980

8081
def test_random_read_write(self):

persistqueue/tests/test_sqlqueue.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def test_open_close_1000(self):
7575
# assert adding another one still works
7676
q.put('foobar')
7777
data = q.get()
78+
q.shrink_disk_usage()
7879
self.assertEqual('foobar', data)
7980

8081
def test_random_read_write(self):

0 commit comments

Comments
 (0)