# Path: sitegeist/mongo.py
# def connect(db="sitegeist"):
# def create_indexes():


import datetime
import logging
from django.conf import settings
from sitegeist.mongo import db
            }
        }

        doc = db.coordcache.find_one(spec)

        if doc:

            now = datetime.datetime.utcnow()

            expsecs = settings.SITEGEIST['COORDCACHE_EXPIRATION'] * 60
            exptime = doc['timestamp'] + datetime.timedelta(seconds=expsecs)

            logger.debug("Comparing cache expiration %s to now %s" % (exptime, now))

            if exptime > now:
                logger.debug("Cache is valid")
                return doc['data']
            else:
                logger.debug("Cache is invalid, deleting document")
                db.coordcache.remove(doc["_id"])

    def set(self, latlon, data):

        doc = {
            'geo': latlon,
            'namespace': self.namespace,
            'data': data,
            'timestamp': datetime.datetime.utcnow(),
        }


# Path: sitegeist/mongo.py
# def connect(db="sitegeist"):
# def create_indexes():


# Path: sitegeist/cache.py
import datetime
import logging
from django.conf import settings
from sitegeist.mongo import db

            }
        }

        doc = db.coordcache.find_one(spec)

        if doc:

            now = datetime.datetime.utcnow()

            expsecs = settings.SITEGEIST['COORDCACHE_EXPIRATION'] * 60
            exptime = doc['timestamp'] + datetime.timedelta(seconds=expsecs)

            logger.debug("Comparing cache expiration %s to now %s" % (exptime, now))

            if exptime > now:
                logger.debug("Cache is valid")
                return doc['data']
            else:
                logger.debug("Cache is invalid, deleting document")
                db.coordcache.remove(doc["_id"])

    def set(self, latlon, data):

        doc = {
            'geo': latlon,
            'namespace': self.namespace,
            'data': data,
            'timestamp': datetime.datetime.utcnow(),
        }


        db.coordcache.insert(doc)