def __init__ (self, base = None, umask = '002', limit = None, **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.umask = int(umask, 0) if sys.platform.startswith("java"): from java.io import File self.file_module = File self.platform = "jython" else: self.platform = "cpython" if not self.access(base, 'read'): self.makedirs(base) self.dbpath = os.path.join(base, 'cache.db') self.limit = None if limit is not None: self.limit = int(limit) #Create the database db = connect(self.dbpath).cursor() for create_table in _create_tables: db.execute(create_table) db.connection.close()
def __init__(self, servers="127.0.0.1:11211", **kwargs): """Constructor""" Cache.__init__(self, **kwargs) if isinstance(servers, string_types): servers = [s.strip() for s in servers.split(",")] self.cache = memcache.Client(servers, debug=0) self.timeout = int(kwargs.get("timeout", 0))
def __init__(self, access_key, secret_access_key, bucket_name, validate="false", is_secure="false", **kwargs): Cache.__init__(self, **kwargs) self.validate = validate.lower() in ["yes", "y", "t", "true"] self.is_secure = is_secure = is_secure.lower() in ["yes", "y", "t", "true"] self.credential = (access_key, secret_access_key) self.bucket_name = bucket_name self._bucket = None self.options = kwargs
def __init__ (self, servers = ['127.0.0.1:9160'], keyspace = "TileCache", column_family = "TileCache", use_ttl="no", **kwargs): Cache.__init__(self, **kwargs) self.keyspace=keyspace self.column_family=column_family if type(servers) is str: servers = map(str.strip, servers.split(",")) self.client = pycassa.connect(keyspace, servers) self.cf = pycassa.ColumnFamily(self.client, column_family)
def __init__ (self, memcache_servers = ['127.0.0.1:11211'], cassandra_nodes = ['127.0.0.1:9160'], keyspace = 'TileCache', **kwargs): Cache.__init__(self, **kwargs) import memcache import pycassa if type(memcache_servers) is str: memcache_servers = map(str.strip, memcache_servers.split(",")) if type(cassandra_nodes) is str: cassandra_nodes = map(str.strip, cassandra_nodes.split(",")) self.memcache = memcache.Client(memcache_servers, debug=0) self.pool = pycassa.ConnectionPool(keyspace=keyspace, server_list=cassandra_nodes, prefill=False) self.cf = pycassa.ColumnFamily(self.pool, "Tiles") self.pycassa = pycassa
def __init__(self, base=None, umask='002', **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.umask = int(umask, 0) if sys.platform.startswith("java"): from java.io import File self.file_module = File self.platform = "jython" else: self.platform = "cpython" if not self.access(base, 'read'): self.makedirs(base)
def __init__ (self, base = None, umask = '002', **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.umask = int(umask, 0) if sys.platform.startswith("java"): from java.io import File self.file_module = File self.platform = "jython" else: self.platform = "cpython" if not self.access(base, 'read'): self.makedirs(base)
def __init__ (self, base = None, sendfile = False, umask = '002', **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.umask = int(umask, 0) self.sendfile = sendfile and sendfile.lower() in ["yes", "y", "t", "true"] if sys.platform.startswith("java"): from java.io import File self.file_module = File self.platform = "jython" else: self.platform = "cpython" if not self.access(base, 'read'): self.makedirs(base)
def __init__ (self, access_key, secret_access_key, bucket_name=None, location='', policy=None, max_age=None, **kwargs): Cache.__init__(self, **kwargs) if policy in s3.acl.CannedACLStrings: self.policy = policy else: self.policy = 'private' self.bucket_name = bucket_name or "%s-tilecache" % access_key.lower() self.cache = s3.connection.S3Connection(access_key, secret_access_key) self.bucket = self.cache.lookup(self.bucket_name) if not self.bucket: self.bucket = self.cache.create_bucket(self.bucket_name, location=location) self.bucket.set_acl(self.policy) if max_age is not None: self.cache_control = {"Cache-Control": "public, max-age=%d"%(int(max_age))} else: self.cache_control = {}
def __init__ (self, base = None, umask = '002', use_tms_paths = "False", **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.umask = int(umask, 0) if sys.platform.startswith("java"): from java.io import File self.file_module = File self.platform = "jython" else: self.platform = "cpython" if not self.access(base, 'read'): self.makedirs(base) if use_tms_paths.lower() in ("true", "yes", "1"): use_tms_paths = True elif use_tms_paths.lower() == "flipped": use_tms_paths = "google" self.use_tms_paths = use_tms_paths
def __init__ (self, access_key, secret_access_key, **kwargs): self.module = None try: import boto.s3 self.s3 = boto.s3 self.module = "boto" except ImportError, E: exceptions = [str(E)] try: import S3 self.s3 = S3 self.module = "amazon" except Exception, E: exceptions.append(str(E)) raise Exception(self.import_error % ('\n * '.join(exceptions))) Cache.__init__(self, **kwargs) self.bucket_name = "%s-tilecache" % access_key.lower() if self.module == "amazon": self.cache = self.s3.AWSAuthConnection(access_key, secret_access_key) self.cache.create_bucket(self.bucket_name) else: self.cache = self.s3.connection.S3Connection(access_key, secret_access_key) self.bucket = self.cache.create_bucket(self.bucket_name) def getBotoKey(self, key): boto_key = self.s3.key.Key(self.bucket) boto_key.key = key return boto_key def getKey(self, tile): return "-".join(map(str, [tile.layer.name, tile.z , tile.x, tile.y]))
def __init__(self, servers=['127.0.0.1:11211'], **kwargs): Cache.__init__(self, **kwargs) import memcache if type(servers) is str: servers = map(str.strip, servers.split(",")) raise Exception(servers) self.cache = memcache.Client(servers, debug=0)
import boto.s3 from connection import S3Connection as Connection from key import Key from bucket import Bucket self.s3 = boto.s3 self.module = "boto" except ImportError, E: exceptions = [str(E)] try: import S3 self.s3 = S3 self.module = "amazon" except Exception, E: exceptions.append(str(E)) raise Exception(self.import_error % ('\n * '.join(exceptions))) Cache.__init__(self, **kwargs) self.bucket_name = "%s-tilecache-%s" % (access_key.lower(), db) if use_tms_paths.lower() in ("true", "yes", "1"): use_tms_paths = True elif use_tms_paths.lower() == "flipped": use_tms_paths = "google" self.use_tms_paths = use_tms_paths if self.module == "amazon": self.cache = self.s3.AWSAuthConnection(access_key, secret_access_key) self.cache.create_bucket(self.bucket_name) else: self.cache = self.s3.connection.S3Connection( access_key, secret_access_key) self.bucket = self.cache.create_bucket(self.bucket_name)
def __init__(self, host, port, expiration=0, **kwargs): """Initialize redis""" Cache.__init__(self, **kwargs) import redis self.cache = redis.StrictRedis(host=host, port=port, db=0) self.expiration = int(expiration)
def __init__(self, base=None, ext=None, umask='002', **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.ext = ext
def __init__(self, url=None, referer='http://map.geo.admin.ch/', **kwargs): Cache.__init__(self, **kwargs) self.host = url self.readonly = True self.headers = {'Referer': referer}
def __init__ (self, base = None, ext = None, umask = '002', **kwargs): Cache.__init__(self, **kwargs) self.basedir = base self.ext = ext
def __init__ (self, **kwargs): Cache.__init__(self, **kwargs) # the Test cache is never readonly self.readonly = False
def __init__ (self, username, api_key, container, **kwargs): Cache.__init__(self, **kwargs) connection = connect_cloudfiles(username, api_key) self.container = connection.get_container(container)
def __init__(self, service): Cache.__init__(self) self.service = service self.basedir = self.get_tiles_path()
def __init__ (self, servers = ['127.0.0.1:11211'], **kwargs): Cache.__init__(self, **kwargs) if type(servers) is str: servers = map(str.strip, servers.split(",")) self.cache = memcache.Client(servers, debug=0)
def __init__(self, servers=['127.0.0.1:11211'], **kwargs): Cache.__init__(self, **kwargs) if type(servers) is str: servers = map(str.strip, servers.split(",")) self.cache = memcache.Client(servers, debug=0) self.timeout = int(kwargs.get('timeout', 0))