UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'emEGkPHNLF1QimzaaMunGZIkEiVub56XFs+SMdActgw=' 
WHERE 
  key_id = '23a140e764263345d7529f366338858c7a6363a54d079a8e85d8e7780c950030' 
  AND (
    token = 'emEGkPHNLF1QimzaaMunGZIkEiVub56XFs+SMdActgw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00042