@param          $key
@param callable $val

@return mixed
777102
public function cache($key, callable $val)
    {
        if (!array_key_exists($key, $this->cache)) {
            $this->cache[$key] = $val();
        }

        return $this->cache[$key];
    }
197853
public function add($key, $val) {
        if (!isset($this->_attrs[$key])) {
            $this->_attrs[$key] = [];
        }
        
        if (!strcasecmp($key, 'id')) {
            // value for `id` should be one only
            $this->_attrs[$key] = $val;
        } else {
            // else append it
            array_push($this->_attrs[$key], $val);
        }
        
        return $this;
    }
515105
public function addSelectizeOption($key, $val)
    {
        if (!is_string($key)) {
            throw new InvalidArgumentException(
                'Setting key must be a string.'
            );
        }

        // Make sure default options are loaded.
        if ($this->selectizeOptions === null) {
            $this->selectizeOptions();
        }

        $this->selectizeOptions[$key] = $val;

        return $this;
    }
867181
protected function form($key, $val)
    {
        $type = null;
        $type = strtolower(__FUNCTION__);

        $this->attributes[self::$formHolder[self::$formName]][$key] =
            "<$type name='".self::$formName."' ".$this->attributes($val).'>'.PHP_EOL;
    }
808195
public function call($key, $callable)
    {
        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Not a valid callable.');
        }

        if ($this->exists($key)) {
            return $this->get($key);
        }

        $args = func_get_args();
        array_shift($args);
        array_shift($args);

        $value = call_user_func_array($callable, $args);

        $this->set($key, $value);

        return $value;
    }
1320223
public function increment($key, $val = 1)
    {
        return $this->hash($key)->incrBy($key, abs(intval($val)));
    }
360245
public function get($key, $default_val = null)
    {
        if ($this->exists($key)) {
            return $this->offsetGet($key);
        }

        return $default_val;
    }
962892
public function setAttribute($key, $val)
    {
        try {
            return $this->_stmt->setAttribute($key, $val);
        } catch (PDOException $e) {
            // require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
        }
    }
613157
protected function makePage($key, $val)
    {
        // Check if it's a divider
        if ($val === '-') {
            return (object) ['divider' => true];
        }

        // Create a new page
        $page = ['url' => $val, 'divider' => false];
        $page = array_merge($page, $this->makeIcon($key));

        // Check if this item is the currently selected one
        $page['active'] = false;
        if (strpos(URL::current(), parse_url($page['url'], PHP_URL_PATH))) {
            $page['active'] = true;
        }

        // Return the new page
        return (object) $page;
    }
1185159
public function set($key, $val = null)
    {
        if (is_array($key)) {
            $this->_setpost = array_merge($this->_setpost, $key);
        } else {
            $this->_setpost[$key] = $val;
        }
        return $this;
    }
669200
public function decrement($key, $val = 1)
    {
        return apc_dec($this->conf['prefix'] . $key, abs(intval($val)));
    }
33819
protected function parseOrderField($query, $key, $val)
    {
        if (isset($val['sort'])) {
            $sort = $val['sort'];
            unset($val['sort']);
        } else {
            $sort = '';
        }

        $sort = strtoupper($sort);
        $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';

        $options = $query->getOptions();
        $bind    = $this->connection->getFieldsBind($options['table']);

        foreach ($val as $k => $item) {
            $val[$k] = $this->parseDataBind($query, $key, $item, $bind);
        }

        return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort;
    }
1061784
function load($key,$val) {
		if ($found=$this->find($key,$val)) {
			$this->id=$found[0]->id;
			return $this->item=$found[0]->item;
		}
		$this->reset();
		return [];
	}
839071
function update( $key, $val = false ) {
			if ( ! is_array( $key ) ) {
				$key = array( $key => $val );
			}

			$is_updated = false;

			foreach ( $key as $k => $v ) {
				if ( $this->{$k} === $v ) {
					continue;
				}

				if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
				       ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
				     $this->{$k} == $v
				) {
					continue;
				}

				// Update value.
				$this->{$k} = $v;

				$is_updated = true;
			}

			$this->_is_updated = $is_updated;

			return $is_updated;
		}
45453
public function _process($val, $map) {
		foreach ($map as $m => $arg) {
			if (is_numeric($m)) {
				$m = $arg;
				$arg = null;
			}

			if ($arg !== null) {
				$ret = call_user_func($m, $val, $arg);
			} else {
				$ret = call_user_func($m, $val);
			}

			if ($ret !== false) {
				$val = $ret;
			}
		}
		return $val;
	}
52387
public function set($key, $val = NULL): QueryBuilderInterface
	{
		if (is_scalar($key))
		{
			$pairs = [$key => $val];
		}
		else
		{
			$pairs = $key;
		}

		$keys = array_keys($pairs);
		$values = array_values($pairs);

		$this->state->appendSetArrayKeys($keys);
		$this->state->appendValues($values);

		// Use the keys of the array to make the insert/update string
		// Escape the field names
		$this->state->setSetArrayKeys(
			array_map([$this->driver, '_quote'], $this->state->getSetArrayKeys())
		);

		// Generate the "set" string
		$setString = implode('=?,', $this->state->getSetArrayKeys());
		$setString .= '=?';

		$this->state->setSetString($setString);

		return $this;
	}
876571
public function increment($key, $val = 1)
    {
        $this->lock = true;
        $v = $this->get($key);
        if (is_int($v)) {
            return $this->update($key, $v + abs(intval($val)));
        } else {
            $this->set($key, 1);
            return 1;
        }
    }