UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'zafMK9gqpPmLNRYs1Wz4FHG7+qirrVel0vrxpRN7G+c=' 
WHERE 
  key_id = '844b6ad7c62daadc5acf401976cd6de25634de413b32c095a7841064ab917121' 
  AND (
    token = 'zafMK9gqpPmLNRYs1Wz4FHG7+qirrVel0vrxpRN7G+c=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040