UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Pyyzt2dvZcfvXaQfx3l8ODeJb8SGF3YaWxtIDzHgbgM=' 
WHERE 
  key_id = '8ec229add16221954871568406081a2e37e842e552eaa634ded8976744f65246' 
  AND (
    token = 'Pyyzt2dvZcfvXaQfx3l8ODeJb8SGF3YaWxtIDzHgbgM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031