{"id":20357870,"url":"https://github.com/gandi/pyramid_kvs","last_synced_at":"2025-04-12T03:14:58.972Z","repository":{"id":15169747,"uuid":"17897505","full_name":"Gandi/pyramid_kvs","owner":"Gandi","description":"Key Value Store utiliites for the python Pyramid framework","archived":false,"fork":false,"pushed_at":"2022-05-13T15:43:55.000Z","size":60,"stargazers_count":4,"open_issues_count":2,"forks_count":5,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-12T03:14:53.617Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"adampmoss/magento-category-seo-heading","license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gandi.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-19T08:55:14.000Z","updated_at":"2022-05-13T15:10:19.000Z","dependencies_parsed_at":"2022-08-25T08:20:35.731Z","dependency_job_id":null,"html_url":"https://github.com/Gandi/pyramid_kvs","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gandi%2Fpyramid_kvs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gandi%2Fpyramid_kvs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gandi%2Fpyramid_kvs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gandi%2Fpyramid_kvs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gandi","download_url":"https://codeload.github.com/Gandi/pyramid_kvs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248510001,"owners_count":21116130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T23:24:17.405Z","updated_at":"2025-04-12T03:14:58.945Z","avatar_url":"https://github.com/Gandi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===========\npyramid_kvs\n===========\n\n.. image:: https://travis-ci.org/Gandi/pyramid_kvs.svg?branch=master\n    :target: https://travis-ci.org/Gandi/pyramid_kvs\n\nSome Key Value Store basics for pyramid:\n\nTwo KVS are implemented:\n - memcache\n - redis\n\nHere are the provides features:\n\n - An application cache, shared by every request.\n - A session manager\n - A rate limit per session holder\n - A perl session reader (except you are migrating a perl website,\n   you probably don't want to use it).\n\nEvery of this components are optional, they exists if they are set in the\nconfiguration like below.\nComponent settings are written in json.\n\nCache\n=====\n\nThe application cache is a new attribute of the session. ``request.cache`` if\nthe settings ``kvs.cache`` exists.\nHere are an example of configuration\n\n::\n\n    kvs.cache = {\"kvs\": \"redis\",\n                 \"codec\": \"pickle\",\n                 \"kvs_kwargs\": {},\n                 \"ttl\": 300,\n                 \"key_prefix\": \"cache::\"}\n\nEvery kvs, except the type are optional.\nThe example contains every key with their default values for a redis instance.\nThe ``kvs_kwargs`` key is passed to the driver to build the client connection.\n\nSession\n=======\n\nThe session is accessible via \"request.session\", it's in every pyramid\napplication.\nThis is just an implementation for Key Value Store users.\n\n::\n\n    kvs.session = {\"kvs\": \"redis\",\n                   \"key_name\": \"session_id\",\n                   \"session_type\": \"cookie\",\n                    \"ttl\": 300,\n                    \"key_prefix\": \"session::\"}\n\n\nEvery kvs, except the type are optional.\nThe example contains every key with their default values for a redis instance.\n\nYou can also create a session for an http header like authentication token,\nit's help to create a cache per user in an API. API don't use cookies.\n\n::\n\n    kvs.session = {\"kvs\": \"redis\",\n                   \"key_name\": \"X-Auth-Token\",\n                   \"session_type\": \"header\",\n                    \"ttl\": 300,\n                    \"key_prefix\": \"session::\"}\n\n\nRatelimit\n=========\n\nThe ratelimit works only if the kvs.session is used!\nRatelimit is per session hold and limit number of http queries in a defined\nperiod.\n\n::\n\n    kvs.ratelimit = {\"window\": 1, \"limit\": 15}\n\nAll keys are optional.\nThe example contains every key with their default values for a redis instance.\n\n\nIf the ratelimit is enabled, every response will be decorated with the\nfollowing http headers:\n\n- ``X-RateLimit-Limit``: max queries in the period.\n- ``X-RateLimit-Remaining``: current remaining queries in that period.\n\n\nperlsess\n========\n\nThis permit to read a session from a perl that use `storable`_ session.\n\n_`storable`: http://search.cpan.org/~ams/Storable-2.45/Storable.pm\n\nHere is an example.\n\n::\n\n\n    # declare the perlsess\n    kvs.perlsess = {\"type\": \"memcached\"}\n\n\nUsage:\n\nDeclare the addons in the ``pyramid.includes`` in your config, then\ntweak the settings like above.\n\n::\n\n    # development.ini\n    [app:main]\n    pyramid.includes =\n        pyramid_kvs\n\n    # declare the application cache\n    # except type, every keys are optional\n    # kvs_kwargs for redis is the parameters of the redis.Redis class\n    # see: http://redis-py.readthedocs.org/en/latest/\n    # for memcache, parameters of the memcache.Client class\n    # https://github.com/linsomniac/python-memcached/blob/master/memcache.py#L160\n    kvs.cache = {\"type\": \"redis\"}\n\n    # declare the session\n    kvs.session = {\"type\": \"redis\"}\n\n    # Authorize a session holder to do 20 http queries max in 2 seconds.\n    kvs.ratelimit = {\"window\": 2, \"limit\": 20}\n\n\ntests\n=====\n\npyramid_kvs have also a 'mock' implementation of a `kvs` used for testing\npurpose, register it using the pyramid plugins in your tests:::\n\n::\n\n  pyramid.includes =\n      pyramid_kvs.testing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgandi%2Fpyramid_kvs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgandi%2Fpyramid_kvs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgandi%2Fpyramid_kvs/lists"}