Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pickledb.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/opt/bin/python2.7
# -*- coding: utf-8 -*-
#
#
#!/usr/bin/env python

# Copyright (c) 2015, Harrison Erd
Expand Down Expand Up @@ -25,6 +29,7 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#

import os
import simplejson
Expand Down Expand Up @@ -56,6 +61,11 @@ def dump(self):
self._dumpdb(True)
return True

def bakdump(self,bakfile):
'''Force dump memory db to file.'''
self._bakdumpdb(True,bakfile)
return True

def set(self, key, value):
'''Set the (string,int,whatever) value of a key'''
self.db[key] = value
Expand Down Expand Up @@ -199,3 +209,8 @@ def _dumpdb(self, forced):
'''Write/save the json dump into the file'''
if forced:
simplejson.dump(self.db, open(self.loco, 'wb'))

def _bakdumpdb(self, forced, bakfile):
'''Write/save the json dump into the file'''
if forced:
simplejson.dump(self.db, open(bakfile, 'wb'))