code: @Override
      public void set(String key, Object entry, long expireAfterWrite, long expireAfterAccess) {
          long ttl = TTL_NO_CHANGE;
          if (!(entry instanceof CacheEntry)) {
              CacheEntry ce = new CacheEntry(key, entry, expireAfterWrite, expireAfterAccess);
              entry = ce;
              ttl = expireAfterAccess > 0 ? expireAfterAccess
                      : (expireAfterWrite > 0 ? expireAfterWrite
                              : (timeToLiveSeconds > 0 ? timeToLiveSeconds : 0));
          } else {
              CacheEntry ce = (CacheEntry) entry;
              ttl = ce.getExpireAfterAccess();
          }
          byte[] _data = serializeCacheEntry((CacheEntry) entry);
          String data = Base64.encodeBase64String(_data);
  
          final int TTL = (int) ttl;
          switch (keyMode) {
          case MONOPOLISTIC:
          case NAMESPACE: {
              final String KEY = keyMode == KeyMode.MONOPOLISTIC ? key : calcCacheKeyNamespace(key);
              try {
                  getMemcachedClient().set(KEY, TTL, data);
              } catch (Exception e) {
                  throw e instanceof CacheException ? (CacheException) e : new CacheException(e);
              }
              break;
          }
          case XNAMESPACE: {
              try {
                  getMemcachedClient().withNamespace(getName(), new MemcachedClientCallable<Void>() {
                      @Override
                      public Void call(MemcachedClient client)
                              throws MemcachedException, InterruptedException, TimeoutException {
                          client.set(key, TTL, data);
                          return null;
                      }
  
                  });
              } catch (Exception e) {
                  throw e instanceof CacheException ? (CacheException) e : new CacheException(e);
              }
              break;
          }
          default:
              throw new IllegalStateException("Invalid key mode: " + keyMode);
          }
      }
docs: {@inheritDoc}