media cache query examples

Manage media cache

Media cache is a read-through caching mechanism for video-on-demand (VOD) streaming with Wowza Streaming Engine™ media server software. Media cache lets you upload and manage content through a centralized location so that you can scale without adding hardware, implementing a content management system, taxing bandwidth and network resources, or increasing latency. You can use the Wowza Streaming Engine REST API to control and manage the media cache system.

Notes:

Get the current Media Cache configuration

View the current Media Cache configuration in a local instance of Wowza Streaming Engine:

Note: You will replace {serverName} with the name of your server.

Example request

curl -X GET \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-Type:application/json; charset=utf-8' \
  http://127.0.0.1:8087/v3/servers/{serverName}/mediacache

Example response

{
  "version": "1489534580000",
  "serverName": "serverName",
  "writerThreadPoolSize": "${com.wowza.wms.TuningAuto}",
  "writerThreadPoolSizeAutoValue": "8",
  "readAheadThreadPoolSize": "${com.wowza.wms.TuningAuto}",
  "readAheadThreadPoolSizeAutoValue": "8",
  "maxPendingWriteRequestSize": "${com.wowza.wms.TuningAuto}",
  "maxPendingWriteRequestSizeAutoValue": "167772160",
  "maxPendingReadAheadRequestSize": "${com.wowza.wms.TuningAuto}",
  "maxPendingReadAheadRequestSizeAutoValue": "83886080",
  "stores": [{
    "storeName": "default",
    "description": "Default Store",
    "path": "${com.wowza.wms.context.ServerConfigHome}/mediacache",
    "maxSize": "10G",
    "writeRate": "16M",
    "writeRateMaxBucketSize": "64M"
  }],
  "sources": [{
    "sourceName": "dvrorigin",
    "type": "HTTP",
    "description": "Default DVR source",
    "basePath": "http://",
    "prefix": "dvrorigin/",
    "minTimeToLive": 14400000,
    "maxTimeToLive": 28800000,
    "isAmazonS3": false,
    "s3BucketNameInDomain": false,
    "awsAccessKeyId": "",
    "awsSecretAccessKey": "",
    "isPassThru": false,
    "baseClass": "com.wowza.wms.mediacache.impl.MediaCacheItemHTTPImpl",
    "httpReaderFactoryClass": "",
    "azureAccountName": "",
    "azureContainerName": "",
    "azureAccountKey": "",
    "googleServiceID": "",
    "googleServiceKey": "",
    "googleServicePrivateKeyFile": "",
    "googleServicePrivateKeyPassword": "",
    "googleEncMethod": ""
  }]
}

Create a Media Cache configuration

Create a Media Cache store in your Wowza Streaming Engine instance:

Note: You will name your store where {storeName} is shown.

Example request

curl -X POST \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-type:application/json; charset=utf-8' \
  http://127.0.0.1:8087/v3/servers/{serverName}/mediacache/stores/{storeName} \
  -d '{
    "path": "${com.wowza.wms.context.ServerConfigHome}/biggerStore2",
    "writeRate": "16M",
    "description": "",
    "storeName": "storeName",
    "maxSize": "3920G",
    "writeRateMaxBucketSize": "64M"
  }'

Example response

{
  "success": true,
  "message": "Saved",
  "data": null
}

Add a Media Cache source

A Media Cache configuration can have multiple sources. A Media Cache source defines the type of content and the location of the content that's available to the Wowza Streaming Engine server. The location might be a local or networked disk, an Amazon S3 bucket, Google Cloud Storage, or a Microsoft Azure Blob storage account.

Note: You will name your source where {sourceName} is shown.

Example request

curl -X POST \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-type:application/json; charset=utf-8' \
  http://127.0.0.1:8087/v3/servers/{serverName}/mediacache/sources/{sourceName} \
  -d '{
    "readerClass": "",
    "isPassThru": false,
    "minTimeToLive": 14400000,
    "maxTimeToLive": 28800000,
    "prefix": "http/",
    "serverName": "",
    "description": "",
    "basePath": "http://192.168.1.1/",
    "baseClass": "com.wowza.wms.mediacache.impl.MediaCacheItemHTTPImpl",
    "type": "HTTP",
    "isAmazonS3": false,
    "s3BucketNameInDomain": false
  }'

Example response

{
  "success": true,
  "message": "Saved",
  "data": null
}

Specify Media Cache source properties

Fine-tune a Media Cache source by specifying properties for it. For a list of Media Cache source properties, see Wowza Streaming Engine MediaCache.xml configuration reference and Configure source properties for Wowza Streaming Engine Media Cache.

Add the httpConnectionTimeout property to the Media Cache source Source2:

Example request

curl -X POST \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-Type:application/json; charset=utf-8' \
  http://127.0.0.1:8087/v3/servers/{serverName}/mediacache/sources/Source2/adv \
  -d '{
    "advancedSettings": [{
      "enabled": true,
      "canRemove": true,
      "name": "httpConnectionTimeout",
      "value": "12000",
      "defaultValue": "6000",
      "type": "Integer",
      "sectionName": "Source2",
      "section": "/Root/MediaCacheSources/MediaCacheSource[Name='{sourceName}']",
      "documented": true
    }]
  }'

Example response

{
  "success": true,
  "message": "Saved",
  "data": null
}

Add a Media Cache store

A Media Cache store defines where the content from the Media Cache source is cached by the Wowza Streaming Engine instance.

Note: You will name your store where {storeName} is shown.

Example request

curl -X POST \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-Type:application/json; charset=utf-8' \
  http://10.0.0.34:8087/v3/servers/{serverName}/mediacache/stores/{storeName} \
  -d '{
    "path": "/partition/large",
    "writeRate": "16M",
    "serverName": "Store2",
    "description": "",
    "storeName": "Store2",
    "maxSize": "500G",
    "writeRateMaxBucketSize": "64M"
  }'

Example response

{
  "success": true,
  "message": "Saved",
  "data": null
}

Specify Media Cache store properties

Fine-tune a Media Cache store by specifying properties for it. For a list of Media Cache store properties, see Wowza Streaming Engine MediaCache.xml configuration reference.

Add the level1FolderCount property to the Media Cache store Store2:

Example request

curl -X POST \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-type:application/json; charset=utf-8' \
  http://10.0.0.34:8087/v2/servers/{serverName}/mediacache/stores/Store2/adv \
  -d '{
    "advancedSettings": [{
      "name": "level1FolderCount",
      "sectionName": "MediaCacheStore/Store2",
      "section": "/Root/MediaCacheStores/MediaCacheStore[Name='{storeName}']",
      "type": "Integer",
      "enabled": true,
      "value": "24",
      "documented": true
    }]
  }'

Example response

{
  "success": true,
  "message": "Saved",
  "data": null
}

Get a list of Media Cache store assets

View a detailed list of Media Cache stores (also called store assets, items, or files) for the default server of a local Wowza Streaming Engine instance:

Example request

curl -X GET \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-Type:application/json; charset=utf-8' \
  http://127.0.0.1:8087/v2/servers/{serverName}/vhosts/{vhostName}/mediacache/stores

Example response

{
  "serverName": "serverName",
  "mediacacheitemlist": [{
    "itemname": "http/asset1.mp4",
    "itemlength": 75190106,
    "itemmaxtimetolive": 0,
    "itemmintimetolive": 0,
    "itemlastrelease": 1454022369252,
    "itemsourcename": "HTTP"
  }, {
    "itemname": "http/asset2.mp4",
    "itemlength": 75230106,
    "itemmaxtimetolive": 0,
    "itemmintimetolive": 0,
    "itemlastrelease": 1454022369450,
    "itemsourcename": "HTTP"
  }]
}

Remove a Media Cache store asset

Remove a store asset (asset2.mp4) that's not in use (option 1):

Example request

curl -X PUT \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-Type:application/json; charset=utf-8' \
  "http://127.0.0.1:8087/v2/servers/{serverName}/vhosts/{vhostName}/mediacache/stores/actions/flushItemFromCache?filename=http/asset2.mp4"

Remove a store asset (asset2.mp4) that's in use:

Example request

curl -X PUT \
  -H 'Accept:application/json; charset=utf-8' \
  -H 'Content-Type:application/json; charset=utf-8' \
  "http://127.0.0.1:8087/v2/servers/{serverName}/vhosts/{vhostName}/mediacache/stores/actions/flushAndForceItemFromCache?filename=http/asset2.mp4"

Example response for both commands

{
  "success": true,
  "message": "Added http/sample.mp4 to flush list",
  "data": null
}