Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can i remove '_PHCR' form the redis

How can i remove '_PHCR' form the redis I work the phalcon with the go and share the redis why should I add the '_PHCR' before the key



78.1k

i might be wrong, but you can't. But I do not understand why that key bothers you ?



55.2k
Accepted
answer

The _PHCR prefix is fixed in the source:

https://github.com/phalcon/cphalcon/blob/f0732e9c2ac4c234afa30fcd4dff1b94d24fe24a/phalcon/cache/backend/redis.zep#L31

You could create your own redis adapter based on that file.

I'm sure that code must be clear, it should tell me what it show me but not hide something for example: I write:

$app->getDI()['cache']->save('app_name', 'google');

somebody(golang) think the String 'google' maybe soted at 'app_name' so:

redisConn = redisPool.Get()
defer redisConn.Close()
appName, err := redisConn.Do('GET', 'app_name')
if err != nil {
    return "", err
}
return appName, nil

It's obvious,it return a error

i might be wrong, but you can't. But I do not understand why that key bothers you ?



78.1k
edited Jun '18

but this key name will always be the same. You can do that in your go app, for example

func (p *redisPool) getSharedKey( name string) (string, error) {
    redisConn := p.Get()
    defer redisConn.Close()
    const phalconKey = "_PHCR"
    v, err := redisConn.Do('GET', name + phalconKey)
    if err != nil {
        return "", err
    }
    return v, nil
}

the example just show the "_PHCR" is not friendly to multi-language development

but this key name will always be the same. You can do that in your go app, for example

func (p *redisPool) getSharedKey( name string) (string, error) {
  redisConn := p.Get()
  defer redisConn.Close()
  const phalconKey = "_PHCR"
  v, err := redisConn.Do('GET', name + phalconKey)
  if err != nil {
      return "", err
  }
  return v, nil
}


78.1k

sharing strings between applications using redis is not "multi-language development" . You need RPC for that