[Python-modules-commits] [python-pyld] 143/276: Remove old ContextCache.

Wolfgang Borgert debacle at moszumanska.debian.org
Wed Oct 8 23:48:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-pyld.

commit 3c3f83a88aa057c40b9c250593a365bb340d0aac
Author: Dave Longley <dlongley at digitalbazaar.com>
Date:   Mon Jul 15 10:21:48 2013 -0400

    Remove old ContextCache.
---
 lib/pyld/jsonld.py | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index a3d45de..54d1318 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -19,7 +19,7 @@ __version__ = '0.2.0'
 __all__ = ['compact', 'expand', 'flatten', 'frame', 'from_rdf', 'to_rdf',
     'normalize', 'set_document_loader', 'load_document',
     'register_rdf_parser', 'unregister_rdf_parser',
-    'JsonLdProcessor', 'ContextCache']
+    'JsonLdProcessor', 'ActiveContextCache']
 
 import copy, hashlib, json, os, re, string, sys, time, traceback
 import urllib2, urlparse, posixpath, socket, ssl
@@ -4251,33 +4251,6 @@ def _is_absolute_iri(v):
     return ':' in v
 
 
-class ContextCache:
-    """
-    A simple JSON-LD context cache.
-    """
-
-    def __init__(self, size=50):
-        self.order = deque()
-        self.cache = {}
-        self.size = size
-        self.expires = 30 * 60 * 1000
-
-    def get(self, url):
-        if url in self.cache:
-            entry = self.cache[url]
-            if entry['expires'] >= time.time():
-                return entry['ctx']
-            del self.cache[url]
-            self.order.remove(url)
-        return None
-
-    def set(self, url, ctx):
-        if(len(self.order) == self.size):
-            del self.cache[self.order.popleft()]
-        self.order.append(url)
-        self.cache[url] = {
-            'ctx': ctx, 'expires': (time.time() + self.expires)}
-
 class ActiveContextCache:
     """
     An ActiveContextCache caches active contexts so they can be reused without

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git



More information about the Python-modules-commits mailing list