Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzing caching issues #27

Open
zopyx opened this issue Nov 30, 2016 · 5 comments
Open

Analyzing caching issues #27

zopyx opened this issue Nov 30, 2016 · 5 comments

Comments

@zopyx
Copy link

zopyx commented Nov 30, 2016

We configured node.ext.ldap according

https://pypi.python.org/pypi/node.ext.ldap#caching-support

However I can not see any cached entries in Memcached using
stats cachedump 1000

on the Memcached console.

Is there any reasonable way to analyze/debug the caching other than taking pdb? Some logging available?

@rnixx
Copy link
Member

rnixx commented Dec 1, 2016

Not really. But actually it would be a good feature to get some cache validation/stats via API.

@rnixx
Copy link
Member

rnixx commented Dec 1, 2016

are you using node.ext.ldap in conjunction with pas.plugins.ldap or standalone? Are you using it in Plone?

@zopyx
Copy link
Author

zopyx commented Dec 1, 2016

Using it in Plone but outside PAS.

@rnixx
Copy link
Member

rnixx commented Dec 1, 2016

pas.plugins.ldap registers it's cache provider factory (https://github.com/collective/pas.plugins.ldap/blob/master/src/pas/plugins/ldap/cache.py#L15) here https://github.com/collective/pas.plugins.ldap/blob/master/src/pas/plugins/ldap/configure.zcml#L30

Cache provider looked happens here https://github.com/bluedynamics/node.ext.ldap/blob/master/src/node/ext/ldap/base.py#L125 if you still need to hook up with pdb.

Hope this helps in the meantime (until some cache verification API is implemented)

@zopyx
Copy link
Author

zopyx commented Dec 2, 2016

Obviously the document registration of the memcached factory did not work for me.

For the sake of completeness: as a workaround I implemented the following:

<utility
  provides="node.ext.ldap.interfaces.ICacheProviderFactory"
  factory=".caching.MemcachedProviderFactory"
/>

@implementer(ICacheProviderFactory)
class MemcachedProviderFactory(object):
    """Memcached cache provider factory.
    """

    def __init__(self, servers=['127.0.0.1:11211']):
        self.servers = None
        servers = os.environ.get('MEMCACHED_SERVERS')
        if not servers:
            LOG.warn('No memcached servers configured')
            return
        servers = servers.split(',')
        for server in servers:
            if ':' not in server:
                raise ValueError('Unable to parse "{}" for memcached configuration. {}'.format(
                    server, config_help))
            ip, port = server.split(':')
            if not is_int(port):
                raise ValueError('Unable to parse "{}" for memcached configuration. {}'.format(
                    server, config_help))
        LOG.info('Configured memcached servers : {}'.format(servers))
        self.servers = servers

    def __call__(self):
        if self.servers:
            return Memcached(self.servers)
        else:
            return NullCache()

@rnixx rnixx added this to the 1.0 milestone May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants