You are here

private function Database::read in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/vendor/ip2location/ip2location-php/IP2Location.php \IP2Location\Database::read()

Low level read function to abstract away the caching mode being used

@access private

Parameters

int $pos Position from where to start reading:

int $len Read this many bytes:

Return value

string

2 calls to Database::read()
Database::readQuad in includes/vendor/ip2location/ip2location-php/IP2Location.php
Low level function to fetch a quadword (128 bits) from the caching backend
Database::readString in includes/vendor/ip2location/ip2location-php/IP2Location.php
Low level function to fetch a string from the caching backend

File

includes/vendor/ip2location/ip2location-php/IP2Location.php, line 1039

Class

Database
IP2Location database class

Namespace

IP2Location

Code

private function read($pos, $len) {
  switch ($this->mode) {
    case self::SHARED_MEMORY:
      return shmop_read($this->resource, $pos, $len);
    case self::MEMORY_CACHE:
      return $data = substr(self::$buffer[$this->resource], $pos, $len);
    default:
      fseek($this->resource, $pos, SEEK_SET);
      return fread($this->resource, $len);
  }
}