{ "info": { "author": "Brendan W. McAdams", "author_email": "bwmcadams@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Other Environment", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Database", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "==============\nmongodb_beaker\n==============\nMongoDB_. backend for Beaker_.'s caching / session system.\n\nBased upon Beaker_.'s ext:memcache code.\n\nThis is implemented in a dont-assume-its-there manner.\nIt uses the beaker namespace as the mongodb row's _id, with everything\nin that namespace ( e.g. a session or cache namespace) stored as a full\ndocument. Each key/value is part of that compound document, using upserts\nfor performance.\n\nI will probably add a toggleable option for using subcollections, as in\ncertain cases such as caching mako templates, this may be desirable /\npreferred performance wise.\n\nRight now, this is primarily optimized for usage with beaker sessions,\nalthough I need to look at tweaking beaker session itself as having it\nstore in individual keys rather than everything in a 'session' key may\nbe desirable for pruning/management/querying.\n\nI have not tackled expiration yet, so you may want to hold off using this\nif you need it. It will be in the next update, but limits usefulness\nprimarily to sessions right now. (I'll tack a cleanup script in later\nas well).\n\nDue to the use of upserts, no check-insert is required, but it will overwrite\nprevious values which should be expected behavior while caching.\nSafe is NOT invoked, so failure will be quiet.\nTODO - Safe as overridable config option?\n\nNote that, unless you disable_. it, the mongodb_beaker container will\nuse pickle (tries loading cpickle first, falls back on pickle) to\nserialize/deserialize data to MongoDB_.\n\n.. _Beaker: http://beaker.groovie.org\n.. _MongoDB: http://mongodb.org\n\n\nBeaker should maintain thread safety on connections internally and so I am\nrelying upon that rather than setting up threadlocal, etc. If this assumption\nis wrong or you run into issues, please let me know.\n\nConfiguration\n=============\n\nTo set this up in your own project so that beaker can find it, it must\ndefine a setuptools entry point in your setup.py file. If you install\nfrom the egg distribution, mongodb_beaker's setup.py SHOULD create a\nbeaker.backend entry point. If you need to tweak it/see how it's done\nor it just doesn't work and you need to define your own,\nmine looks like this::\n\n >>> entry_points=\"\"\"\n ... [beaker.backends]\n ... mongodb = mongodb_beaker:MongoDBNamespaceManager\n ... \"\"\",\n\n\nWith this defined, beaker should automatically find the entry point at startup\n(Beaker 1.4 and higher support custom entry points) and load it as an optional\nbackend called 'mongodb'. There are several ways to configure Beaker, I only\ncover ini file (such as with Pylons) here. There are more configuration\noptions and details in the Beaker configuration docs [1]_.\n\n.. [1] Beaker's configuration documentation -\n http://beaker.groovie.org/configuration.htm\n\nI have a few cache regions in one of my applications, some of which are memcache and some are on mongodb. The region config looks like this::\n\n >>> # new style cache settings\n ... beaker.cache.regions = comic_archives, navigation\n ... beaker.cache.comic_archives.type = libmemcached\n ... beaker.cache.comic_archives.url = 127.0.0.1:11211\n ... beaker.cache.comic_archives.expire = 604800\n ... beaker.cache.navigation.type = mongodb\n ... beaker.cache.navigation.url = mongodb://localhost:27017/beaker.navigation\n ... beaker.cache.navigation.expire = 86400\n \nThe Beaker docs[1] contain detailed information on configuring regions. The\nitem we're interested in here is the **beaker.cache.navigation** keys. Each\nbeaker cache definition needs a *type* field, which defines which backend to\nuse. Specifying mongodb will (if the module is properly installed) tell\nBeaker to cache via mongodb. Note that if Beaker cannot load the extension,\nit will tell you that mongodb is an invalid backend.\n\nExpiration is standard beaker syntax, although not supported at the moment in\nthis backend.\n\nFinally, you need to define a URL to connect to MongoDB. This follows the standardized\nMongoDB URI Format[3]_. Currently the only options supported is 'slaveOK'.\nFor backwards compatibility with old versions of mongodb_beaker, separating\ndatabase and collection with a '#' instead of '.' is supported, but deprecated.\nThe syntax is mongodb://[:port]/.\n\nYou must define a collection for MongoDB to store data in, in addition to a database.\n\nIf you want to use MongoDB's optional authentication support, that is also supported. Simply define your URL as such::\n\n >>> beaker.cache.navigation.url = mongodb://bwmcadams@passW0Rd?@localhost:27017/beaker.navigation\n\nThe mongodb_beaker backend will attempt to authenticate with the username and\npassword. You must configure MongoDB's optional authentication support[2]_ for\nthis to work (By default MongoDB doesn't use authentication).\n\n.. [2] MongoDB Authentication Documentation: http://www.mongodb.org/display/DOCS/Security+and+Authentication\n.. [3] MongoDB URI Format: http://www.mongodb.org/display/DOCS/Connections\n\n\nReading from Secondaries (SlaveOK)\n==================================\n\nIf you'd like to enable reading from secondaries (SlaveOK), you can add that to your URL::\n\n >>> beaker.cache.navigation.url = mongodb://bwmcadams@passW0Rd?@localhost:27017/beaker.navigation?slaveok=true\n\n\nUsing Beaker Sessions and disabling pickling\n=============================================\n\n.. _disable:\n\nIf you want to save some CPU cycles and can guarantee that what you're\npassing in is either \"mongo-safe\" and doesn't need pickling, or you know\nit's already pickled (such as while using beaker sessions), you can set an\nextra beaker config flag of skip_pickle=True. ``.. admonition:: To make that\nperfectly clear, Beaker sessions are ALREADY PASSED IN pickled, so you want to\nconfigure it to skip_pickle.`` It shouldn't hurt anything to double-pickle,\nbut you will certainly waste precious CPU cycles. And wasting CPU cycles is\nkind of counterproductive in a caching system.\n\nMy pylons application configuration for mongodb_beaker has the\nfollowing session_configuration::\n\n >>> beaker.session.type = mongodb\n ... beaker.session.url = mongodb://localhost:27017/beaker.sessions\n ... beaker.session.skip_pickle = True\n\nDepending on your individual needs, you may also wish to create a\ncapped collection for your caching (e.g. memcache-like only most recently used storage)\n\nSee the MongoDB CappedCollection_. docs for details.\n\n.. _CappedCollection: http://www.mongodb.org/display/DOCS/Capped+Collections\n\nSparse Collection Support\n=========================\n\nThe default behavior of mongodb_beaker is to create a single MongoDB Document for each namespace, and store each \ncache key/value on that document. In this case, the \"_id\" of the document will be the namespace, and each new cache entry\nwill be attached to that document.\n\nThis approach works well in many cases and makes it very easy for Mongo to efficiently manage your cache. However, in other cases\nyou may wish to change behavior. This may be for efficiency reasons, or because you're worried about documents getting too large.\n\nIn this case, you can enable a \"sparse collection\" mode, where mongodb_beaker will create a document for EACH key in the namespace.\nWhen sparse collections are enabled, the \"_id\" of a document is a compound document containing the namespace and the key::\n\n { \"_id\" : { \"namespace\" : \"testcache\", \"key\" : \"value\" } }\n\nThe cache data for that key will be stored in a document field 'data'. You can enable sparse collections in your config with the\n'sparse_collections' variable::\n\n >>> beaker.session.type = mongodb\n ... beaker.session.url = mongodb://localhost:27017/beaker.sessions\n ... beaker.session.sparse_collections = True\n\nNote for Users of Previous Releases\n====================================\n\nFor bug fix and feature reasons, MongoDB Beaker 0.5+ are not compatible with caches created by previous releases.\nBecause this is cache data, it shouldn't be a big deal. We recommend dropping or flushing your entire cache collection(s)\nbefore upgrading to 0.5+ and be aware that it will generate new caches.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/bwmcadams/mongodb_beaker/", "keywords": "mongo mongodb beaker cache session", "license": "New BSD License", "maintainer": null, "maintainer_email": null, "name": "mongodb-beaker2", "package_url": "https://pypi.org/project/mongodb-beaker2/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mongodb-beaker2/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/bwmcadams/mongodb_beaker/" }, "release_url": "https://pypi.org/project/mongodb-beaker2/0.5.1/", "requires_dist": null, "requires_python": null, "summary": "Beaker backend to write sessions and caches to a MongoDB schemaless database. This package adds the README.rst which was missing from the MANIFEST.in file. Please refer to the original author (Brendan W. McAdams - bwmcadams@gmail.com) regarding any question related to this package.", "version": "0.5.1" }, "last_serial": 769870, "releases": { "0.5.1": [ { "comment_text": "", "digests": { "md5": "16f2da79de06ad62d76b9f0739a5461c", "sha256": "2ada1a5d71294798caebc077c01192bfc04dc35f2b700fdbea1f801f8c4abbf8" }, "downloads": -1, "filename": "mongodb_beaker_-0.5.1.tar.gz", "has_sig": false, "md5_digest": "16f2da79de06ad62d76b9f0739a5461c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13667, "upload_time": "2012-09-11T18:27:57", "url": "https://files.pythonhosted.org/packages/16/2d/7f601fad316edbb1bfa9d547796ebeffb3bff97f8b6a0d578bf2526b304c/mongodb_beaker_-0.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "16f2da79de06ad62d76b9f0739a5461c", "sha256": "2ada1a5d71294798caebc077c01192bfc04dc35f2b700fdbea1f801f8c4abbf8" }, "downloads": -1, "filename": "mongodb_beaker_-0.5.1.tar.gz", "has_sig": false, "md5_digest": "16f2da79de06ad62d76b9f0739a5461c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13667, "upload_time": "2012-09-11T18:27:57", "url": "https://files.pythonhosted.org/packages/16/2d/7f601fad316edbb1bfa9d547796ebeffb3bff97f8b6a0d578bf2526b304c/mongodb_beaker_-0.5.1.tar.gz" } ] }