UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'gel20PAvS8f5yaLwkVNvGTeE46pypaemMgc35SXFDdw=' 
WHERE 
  key_id = 'a3fc3986b60cb4bef5cb04798fe32e8883a5794df4a915f36c2f9000a25491b2' 
  AND (
    token = 'gel20PAvS8f5yaLwkVNvGTeE46pypaemMgc35SXFDdw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00051